Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ef585de

Browse files
committed
Fix two-phase commit test for recovery mode
The original code had a race condition because it never ensured the standby was caught up before proceeding; add a wait similar to every other place that does this. Author: Michaël Paquier Discussion: https://postgr.es/m/CAB7nPqTm9p+LCm1mVJYvgpwagRK+uibT-pKq0O2-paOWxT62jw@mail.gmail.com
1 parent f15b76a commit ef585de

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/recovery/t/009_twophase.pl

+8
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,14 @@ sub configure_and_reload
331331
CHECKPOINT;
332332
COMMIT PREPARED 'xact_009_13';");
333333

334+
# Ensure that last transaction is replayed on standby.
335+
my $cur_master_lsn =
336+
$cur_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
337+
my $caughtup_query =
338+
"SELECT '$cur_master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()";
339+
$cur_standby->poll_query_until('postgres', $caughtup_query)
340+
or die "Timed out while waiting for standby to catch up";
341+
334342
$cur_standby->psql(
335343
'postgres',
336344
"SELECT count(*) FROM t_009_tbl2",

0 commit comments

Comments
 (0)