v50-0003-Additional-test-to-validate-the-restart_lsn-of-s.patch

application/octet-stream

Filename: v50-0003-Additional-test-to-validate-the-restart_lsn-of-s.patch
Type: application/octet-stream
Part: 0
Message: Re: Synchronizing slots from primary to standby

Patch

Format: format-patch
Series: patch v50-0003
Subject: Additional test to validate the restart_lsn of synced slot
File+
src/test/recovery/t/050_standby_failover_slots_sync.pl 33 3
From da36d6161e79b1fcdbf5d69e745143e5a7b9f9ac 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 v50 3/3] Additional test to validate the restart_lsn of synced
 slot

---
 .../t/050_standby_failover_slots_sync.pl      | 36 +++++++++++++++++--
 1 file changed, 33 insertions(+), 3 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 277fc2e079..4b65befc65 100644
--- a/src/test/recovery/t/050_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/050_standby_failover_slots_sync.pl
@@ -357,6 +357,37 @@ 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
+##################################################
+
+# Truncate table on primary
+$primary->safe_psql('postgres',
+	"TRUNCATE TABLE tab_int;");
+
+# 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';");
+
+# Insert data on the primary
+$primary->safe_psql('postgres',
+	"INSERT INTO tab_int SELECT generate_series(1, 10);");
+
+# Confirm that restart_lsn of lsub1_slot slot is synced to the standby
+$result = $standby1->safe_psql('postgres',
+	qq[SELECT '$primary_restart_lsn' <= restart_lsn from pg_replication_slots WHERE slot_name = 'lsub1_slot';]);
+is($result, 't', 'restart_lsn of slot lsub1_slot synced to standby');
+
+# Confirm that confirmed_flush_lsn of lsub1_slot slot is synced to the standby
+$result = $standby1->safe_psql('postgres',
+	qq[SELECT '$primary_flush_lsn' <= confirmed_flush_lsn from pg_replication_slots WHERE slot_name = 'lsub1_slot';]);
+is($result, 't', 'confirmed_flush_lsn of slot lsub1_slot synced to the standby');
+
 ##################################################
 # Test that a synchronized slot can not be decoded, altered and dropped by the user
 ##################################################
@@ -432,14 +463,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.34.1