Skip to content

Commit fd39c3c

Browse files
committed
Improve the stability of the recovery test 047_checkpoint_physical_slot
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
1 parent 6aefde2 commit fd39c3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@
9797
q{select pg_replication_slot_advance('slot_physical', pg_current_wal_lsn())}
9898
);
9999

100-
# Continue the checkpoint.
100+
# Continue the checkpoint and wait for its completion.
101+
my $log_offset = -s $node->logfile;
101102
$node->safe_psql('postgres',
102103
q{select injection_points_wakeup('checkpoint-before-old-wal-removal')});
104+
$node->wait_for_log(qr/checkpoint complete/, $log_offset);
103105

104106
my $restart_lsn_old = $node->safe_psql('postgres',
105107
q{select restart_lsn from pg_replication_slots where slot_name = 'slot_physical'}
106108
);
107109
chomp($restart_lsn_old);
108110
note("restart lsn before stop: $restart_lsn_old");
109111

110-
# Abruptly stop the server (1 second should be enough for the checkpoint
111-
# to finish; it would be better).
112+
# Abruptly stop the server.
112113
$node->stop('immediate');
113114

114115
$node->start;

0 commit comments

Comments
 (0)