]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve the stability of the recovery test 047_checkpoint_physical_slot
authorAlexander Korotkov <akorotkov@postgresql.org>
Sat, 19 Jul 2025 10:51:07 +0000 (13:51 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Sat, 19 Jul 2025 10:51:34 +0000 (13:51 +0300)
Currently, the comments in 047_checkpoint_physical_slot. It shows an
incomplete intention to wait for checkpoint completion before performing
an immediate database stop.  However, an immediate node stop can occur both
before and after checkpoint completion.  Both cases should work correctly.
But we would like the test to be more stable and deterministic.  This is why
this commit makes this test explicitly wait for the checkpoint completion
log message.

Discussion: https://postgr.es/m/CAPpHfdurV-j_e0pb%3DUFENAy3tyzxfF%2ByHveNDNQk2gM82WBU5A%40mail.gmail.com
Discussion: https://postgr.es/m/aHXLep3OaX_vRTNQ%40paquier.xyz
Author: Alexander Korotkov <akorotkov@postgresql.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 17

src/test/recovery/t/047_checkpoint_physical_slot.pl

index 643cb6a7bcb9b655baa5a37f7d2757c3a12cfaff..a909bf2ba0171a9afead9701dbf322fd0f199434 100644 (file)
@@ -97,9 +97,11 @@ $node->safe_psql('postgres',
        q{select pg_replication_slot_advance('slot_physical', pg_current_wal_lsn())}
 );
 
-# Continue the checkpoint.
+# Continue the checkpoint and wait for its completion.
+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);
 
 my $restart_lsn_old = $node->safe_psql('postgres',
        q{select restart_lsn from pg_replication_slots where slot_name = 'slot_physical'}
@@ -107,8 +109,7 @@ my $restart_lsn_old = $node->safe_psql('postgres',
 chomp($restart_lsn_old);
 note("restart lsn before stop: $restart_lsn_old");
 
-# 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;