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

application/octet-stream

Filename: v49-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 v49-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 9d18ad194ddb6e725c5d784a17a7308b6e0219ce Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Mon, 18 Dec 2023 19:26:01 +0800
Subject: [PATCH v49 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 33af515d83..3f047437a0 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 synchronized slot can neither be decoded nor dropped by the user
 ##################################################
@@ -422,14 +453,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_mypub3 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