diff --git a/src/bin/pg_rewind/RewindTest.pm b/src/bin/pg_rewind/RewindTest.pm index b66ff0d..fce725f 100644 --- a/src/bin/pg_rewind/RewindTest.pm +++ b/src/bin/pg_rewind/RewindTest.pm @@ -232,6 +232,13 @@ sub promote_standby #### Now run the test-specific parts to run after standby has been started # up standby + # Wait until the standby has caught up with the primary, by polling + # pg_stat_replication. + my $caughtup_query = +"SELECT pg_current_xlog_location() = replay_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';"; + poll_query_until($caughtup_query, $connstr_master) + or die "Timed out while waiting for standby to catch up"; + # Now promote slave and insert some new data on master, this will put # the master out-of-sync with the standby. Wait until the standby is # out of recovery mode, and is ready to accept read-write connections.