From 38c67b0fd8f2d83e97a93108484fe23c881dd91c Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Mon, 8 May 2023 07:02:50 +0000 Subject: [PATCH v1] fix retaining WAL test --- .../t/035_standby_logical_decoding.pl | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) 100.0% src/test/recovery/t/ diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl index ad1def2474..4bda706eae 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -276,20 +276,6 @@ $node_standby->append_conf('postgresql.conf', max_replication_slots = 5]); $node_standby->start; $node_primary->wait_for_replay_catchup($node_standby); -$node_standby->safe_psql('testdb', qq[SELECT * FROM pg_create_physical_replication_slot('$standby_physical_slotname');]); - -####################### -# Initialize cascading standby node -####################### -$node_standby->backup($backup_name); -$node_cascading_standby->init_from_backup( - $node_standby, $backup_name, - has_streaming => 1, - has_restoring => 1); -$node_cascading_standby->append_conf('postgresql.conf', - qq[primary_slot_name = '$standby_physical_slotname']); -$node_cascading_standby->start; -$node_standby->wait_for_replay_catchup($node_cascading_standby, $node_primary); ####################### # Initialize subscriber node @@ -503,9 +489,6 @@ check_slots_conflicting_status(1); # Verify that invalidated logical slots do not lead to retaining WAL. ################################################## -# Wait for the cascading standby to catchup before removing the WAL file(s) -$node_standby->wait_for_replay_catchup($node_cascading_standby, $node_primary); - # Get the restart_lsn from an invalidated slot my $restart_lsn = $node_standby->safe_psql('postgres', "SELECT restart_lsn from pg_replication_slots WHERE slot_name = 'vacuum_full_activeslot' and conflicting is true;" @@ -538,6 +521,27 @@ my $standby_walfile = $node_standby->data_dir . '/pg_wal/' . $walfile_name; ok(!-f "$standby_walfile", "invalidated logical slots do not lead to retaining WAL"); +# Now create the physical slot on the standby and initialize the cascading standby node. +# It's done here because the physical slot on the standby could prevent the WAL +# file to be removed in the test above (ensuring the WAL file removal could still be +# possible but we want to keep the above test simple). +# Also please note that the cascading standby will be created with hot_standby_feedback +# set to on thanks to the last change_hot_standby_feedback_and_wait_for_xmins() call. +$node_standby->safe_psql('testdb', qq[SELECT * FROM pg_create_physical_replication_slot('$standby_physical_slotname');]); + +####################### +# Initialize cascading standby node +####################### +$node_standby->backup($backup_name); +$node_cascading_standby->init_from_backup( + $node_standby, $backup_name, + has_streaming => 1, + has_restoring => 1); +$node_cascading_standby->append_conf('postgresql.conf', + qq[primary_slot_name = '$standby_physical_slotname']); +$node_cascading_standby->start; +$node_standby->wait_for_replay_catchup($node_cascading_standby, $node_primary); + ################################################## # Recovery conflict: Invalidate conflicting slots, including in-use slots # Scenario 2: conflict due to row removal with hot_standby_feedback off. -- 2.34.1