Skip to content

Commit 582fbff

Browse files
committed
In the pg_rewind test suite, receive WAL fully before promoting.
If a transaction never reaches the standby, later tests find unexpected cluster state. A "tail-copy: query result matches" test failure has been the usual symptom. Among the buildfarm members having run this test suite, most have exhibited that symptom at least once. Back-patch to 9.5, where pg_rewind was introduced. Michael Paquier, reported by Christoph Berg.
1 parent b1e1862 commit 582fbff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/pg_rewind/RewindTest.pm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,21 @@ recovery_target_timeline='latest'
222222
'-l', "$log_path/standby.log",
223223
'-o', "-p $port_standby", 'start');
224224

225-
# Wait until the standby has caught up with the primary, by polling
226-
# pg_stat_replication.
227-
my $caughtup_query =
228-
"SELECT pg_current_xlog_location() = replay_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
229-
poll_query_until($caughtup_query, $connstr_master)
230-
or die "Timed out while waiting for standby to catch up";
225+
# The standby may have WAL to apply before it matches the primary. That
226+
# is fine, because no test examines the standby before promotion.
231227
}
232228

233229
sub promote_standby
234230
{
235231
#### Now run the test-specific parts to run after standby has been started
236232
# up standby
237233

234+
# Wait for the standby to receive and write all WAL.
235+
my $wal_received_query =
236+
"SELECT pg_current_xlog_location() = write_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
237+
poll_query_until($wal_received_query, $connstr_master)
238+
or die "Timed out while waiting for standby to receive and write WAL";
239+
238240
# Now promote slave and insert some new data on master, this will put
239241
# the master out-of-sync with the standby. Wait until the standby is
240242
# out of recovery mode, and is ready to accept read-write connections.

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