v51_2-0003-Additional-test-to-validate-the-restart_lsn-of-s.patch
application/octet-stream
Filename: v51_2-0003-Additional-test-to-validate-the-restart_lsn-of-s.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v51-0003
Subject: Additional test to validate the restart_lsn of synced slot
| File | + | − |
|---|---|---|
| src/test/recovery/t/050_standby_failover_slots_sync.pl | 42 | 5 |
From 5efafe70ce7cc299e8dcfd96e121687029b667d3 Mon Sep 17 00:00:00 2001
From: Shveta Malik <shveta.malik@gmail.com>
Date: Tue, 19 Dec 2023 16:31:49 +0530
Subject: [PATCH v51 3/3] Additional test to validate the restart_lsn of synced
slot
---
.../t/050_standby_failover_slots_sync.pl | 47 +++++++++++++++++--
1 file changed, 42 insertions(+), 5 deletions(-)
diff --git a/src/test/recovery/t/050_standby_failover_slots_sync.pl b/src/test/recovery/t/050_standby_failover_slots_sync.pl
index cda99e9791..7739c8b0c6 100644
--- a/src/test/recovery/t/050_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/050_standby_failover_slots_sync.pl
@@ -358,6 +358,45 @@ is($standby1->safe_psql('postgres',
"t|r",
'logical slot has failover as true and sync_state as ready on standby');
+##################################################
+# Test to confirm that restart_lsn and confirmed_flush_lsn of the logical slot
+# on the primary is synced to the standby
+##################################################
+
+# Insert data on the primary
+$primary->safe_psql(
+ 'postgres', qq[
+ TRUNCATE TABLE tab_int;
+ INSERT INTO tab_int SELECT generate_series(1, 10);
+]);
+
+$primary->wait_for_catchup('regress_mysub1');
+
+# Do not allow any further advancement of the restart_lsn and
+# confirmed_flush_lsn for the lsub1_slot.
+$subscriber1->safe_psql('postgres', "ALTER SUBSCRIPTION regress_mysub1 DISABLE");
+
+# Wait for the replication slot to become inactive on the publisher
+$primary->poll_query_until(
+ 'postgres',
+ "SELECT COUNT(*) FROM pg_catalog.pg_replication_slots WHERE slot_name = 'lsub1_slot' AND active='f'",
+ 1);
+
+# Get the restart_lsn for the logical slot lsub1_slot on the primary
+my $primary_restart_lsn = $primary->safe_psql('postgres',
+ "SELECT restart_lsn from pg_replication_slots WHERE slot_name = 'lsub1_slot';");
+
+# Get the confirmed_flush_lsn for the logical slot lsub1_slot on the primary
+my $primary_flush_lsn = $primary->safe_psql('postgres',
+ "SELECT confirmed_flush_lsn from pg_replication_slots WHERE slot_name = 'lsub1_slot';");
+
+# Confirm that restart_lsn and of confirmed_flush_lsn lsub1_slot slot are synced
+# to the standby
+ok( $standby1->poll_query_until(
+ 'postgres',
+ "SELECT '$primary_restart_lsn' = restart_lsn AND '$primary_flush_lsn' = confirmed_flush_lsn from pg_replication_slots WHERE slot_name = 'lsub1_slot';"),
+ 'restart_lsn and confirmed_flush_lsn of slot lsub1_slot synced to standby');
+
##################################################
# Test that a synchronized slot can not be decoded, altered and dropped by the user
##################################################
@@ -423,8 +462,7 @@ $standby1->promote;
# Update subscription with the new primary's connection info
$subscriber1->safe_psql('postgres',
- "ALTER SUBSCRIPTION regress_mysub1 DISABLE;
- ALTER SUBSCRIPTION regress_mysub1 CONNECTION '$standby1_conninfo';
+ "ALTER SUBSCRIPTION regress_mysub1 CONNECTION '$standby1_conninfo';
ALTER SUBSCRIPTION regress_mysub1 ENABLE; ");
is($standby1->safe_psql('postgres',
@@ -433,14 +471,13 @@ is($standby1->safe_psql('postgres',
'synced slot retained on the new primary');
# Insert data on the new primary
-$primary_row_count = 10;
$standby1->safe_psql('postgres',
- "INSERT INTO tab_int SELECT generate_series(1, $primary_row_count);");
+ "INSERT INTO tab_int SELECT generate_series(11, 20);");
$standby1->wait_for_catchup('regress_mysub1');
# Confirm that data in tab_int replicated on subscriber
is( $subscriber1->safe_psql('postgres', q{SELECT count(*) FROM tab_int;}),
- "$primary_row_count",
+ "20",
'data replicated from the new primary');
done_testing();
--
2.30.0.windows.2