]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve recovery test 046_checkpoint_logical_slot
authorAlexander Korotkov <akorotkov@postgresql.org>
Thu, 17 Jul 2025 21:04:52 +0000 (00:04 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Sat, 19 Jul 2025 10:45:16 +0000 (13:45 +0300)
This commit improves 046_checkpoint_logical_slot in two aspects:
- Add one pg_logical_emit_message() call to force the creation of a record
  that spawns across two pages.
- Make the logic wait for the checkpoint completion.

Discussion: https://postgr.es/m/CALDaNm34m36PDHzsU_GdcNXU0gLTfFY5rzh9GSQv%3Dw6B%2BQVNRQ%40mail.gmail.com
Author: Alexander Korotkov <akorotkov@postgresql.org>
Co-authored-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
src/test/recovery/t/046_checkpoint_logical_slot.pl

index 0468d4609e43b6d994e1f62f3dc9357be3e3d428..d2cf1cb4464e65db30f9d822ed4ec71ce1003b4b 100644 (file)
@@ -119,12 +119,18 @@ $node->safe_psql('postgres',
        q{select pg_replication_slot_advance('slot_physical', pg_current_wal_lsn())}
 );
 
+# Generate a long WAL record, spawning at least two pages for the follow-up
+# post-recovery check.
+$node->safe_psql('postgres',
+       q{select pg_logical_emit_message(false, '', repeat('123456789', 1000))});
+
 # Continue the checkpoint.
+my $log_offset = -s $node->logfile;
 $node->safe_psql('postgres',
        q{select injection_points_wakeup('checkpoint-before-old-wal-removal')});
+$node->wait_for_log(qr/checkpoint complete/, $log_offset);
 
-# Abruptly stop the server (1 second should be enough for the checkpoint
-# to finish; it would be better).
+# Abruptly stop the server.
 $node->stop('immediate');
 
 $node->start;