Skip to content

Commit 89c59b7

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 a6979c3 commit 89c59b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy