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

Commit bd8fc16

Browse files
author
Amit Kapila
committed
Fix BF introduced in commit ddd5f4f.
The failure is that the remote slot is not synchronized after the same slot on standby gets invalidated. The reason was that remote_slot's restart_lsn was lagged behind the standby's oldest WAL segment. The test didn't ensure that remote_slot's LSN was advanced to the latest position before we tried to sync the slots via new the function pg_sync_replication_slots(). Discussion: https://postgr.es/m/CAA4eK1JLBi3HzenB6do3_hd78kN0UDD1mz-vumWE52XHHEq5Bw@mail.gmail.com
1 parent b8f9e77 commit bd8fc16

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/test/recovery/t/040_standby_failover_slots_sync.pl

+9-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
# flagged as 'synced'
172172
is( $standby1->safe_psql(
173173
'postgres',
174-
q{SELECT count(*) = 2 FROM pg_replication_slots WHERE slot_name IN ('lsub1_slot', 'lsub2_slot') AND synced;}
174+
q{SELECT count(*) = 2 FROM pg_replication_slots WHERE slot_name IN ('lsub1_slot', 'lsub2_slot') AND synced AND NOT temporary;}
175175
),
176176
"t",
177177
'logical slots have synced as true on standby');
@@ -227,6 +227,13 @@
227227
$subscriber1->safe_psql('postgres',
228228
"ALTER SUBSCRIPTION regress_mysub1 ENABLE");
229229

230+
# This wait ensures that confirmed_flush_lsn has been moved to latest
231+
# position.
232+
$primary->wait_for_catchup('regress_mysub1');
233+
234+
# To ensure that restart_lsn has moved to a recent WAL position, we need
235+
# to log XLOG_RUNNING_XACTS and make sure the same is processed as well
236+
$primary->psql('postgres', "CHECKPOINT");
230237
$primary->wait_for_catchup('regress_mysub1');
231238

232239
# Do not allow any further advancement of the restart_lsn for the lsub1_slot.
@@ -256,7 +263,7 @@
256263
# flagged as 'synced'
257264
is( $standby1->safe_psql(
258265
'postgres',
259-
q{SELECT conflict_reason IS NULL AND synced FROM pg_replication_slots WHERE slot_name = 'lsub1_slot';}
266+
q{SELECT conflict_reason IS NULL AND synced AND NOT temporary FROM pg_replication_slots WHERE slot_name = 'lsub1_slot';}
260267
),
261268
"t",
262269
'logical slot is re-synced');

0 commit comments

Comments
 (0)