diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-09-01 16:51:55 +0200 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-09-01 16:51:55 +0200 |
commit | 89c59b742a7f89eb598a25b70aaa3ab97381f67d (patch) | |
tree | 41c0493188137859467dab900b393797c66b6234 /src | |
parent | a6979c3a68e2caa6696021f7a15278a99e7409a1 (diff) | |
download | postgresql-89c59b742a7f89eb598a25b70aaa3ab97381f67d.tar.gz postgresql-89c59b742a7f89eb598a25b70aaa3ab97381f67d.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/test/recovery/t/009_twophase.pl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/recovery/t/009_twophase.pl b/src/test/recovery/t/009_twophase.pl index 6c501395722..95f22bc4210 100644 --- a/src/test/recovery/t/009_twophase.pl +++ b/src/test/recovery/t/009_twophase.pl @@ -331,6 +331,14 @@ $cur_master->psql( CHECKPOINT; COMMIT PREPARED 'xact_009_13';"); +# Ensure that last transaction is replayed on standby. +my $cur_master_lsn = + $cur_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()"); +my $caughtup_query = + "SELECT '$cur_master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()"; +$cur_standby->poll_query_until('postgres', $caughtup_query) + or die "Timed out while waiting for standby to catch up"; + $cur_standby->psql( 'postgres', "SELECT count(*) FROM t_009_tbl2", |