summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2023-05-09 14:25:33 +0530
committerAmit Kapila <akapila@postgresql.org>2023-05-09 14:25:33 +0530
commitc5b7f67fcc8c4a01c82660eb0996a3c697fac283 (patch)
tree6b0927f5518ba092d9c35cd29dc11172e8fbe74f
parent3d144c6c86025272e1711539f5fafb6fb85c4feb (diff)
downloadpostgresql-c5b7f67fcc8c4a01c82660eb0996a3c697fac283.tar.gz
Fix the race condition in the test case added by commit a6e04b1d20.
The commit a6e04b1d20 added a test to ensure that the invalidated logical slots don't retain WAL. The test was ensuring that the checkpoint removes the WAL files corresponding to invalidated logical slots on the standby node but missed the point that the standby node also had a physical slot which led to the prevention of WAL file removal. Move the creation of physical slot on the standby and initialization of cascading standby closer to the test case that actually required it so that other tests don't get affected by the presence of the physical slot on standby. Author: Bertrand Drouvot Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/2fefa454-5a70-2174-ddbf-4a0e41537139@gmail.com
-rw-r--r--src/test/recovery/t/035_standby_logical_decoding.pl36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index ad1def2474..2b4a688330 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;"
@@ -777,9 +760,26 @@ $node_standby->reload;
$node_primary->psql('postgres', q[CREATE DATABASE testdb]);
$node_primary->safe_psql('testdb', qq[CREATE TABLE decoding_test(x integer, y text);]);
-# Wait for the standby to catchup before creating the slots
+# Wait for the standby to catchup before initializing the cascading standby
$node_primary->wait_for_replay_catchup($node_standby);
+# Create a physical replication slot on the standby.
+# Keep this step after the "Verify that invalidated logical slots do not lead
+# to retaining WAL" test (as the physical slot on the standby could prevent the
+# WAL file removal).
+$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'
+ hot_standby_feedback = on]);
+$node_cascading_standby->start;
+
# create the logical slots
create_logical_slots($node_standby, 'promotion_');