public inbox for [email protected]
help / color / mirror / Atom feedFrom: Amit Kapila <[email protected]>
To: Zhijie Hou (Fujitsu) <[email protected]>
Cc: Peter Smith <[email protected]>
Cc: shveta malik <[email protected]>
Cc: Masahiko Sawada <[email protected]>
Cc: Ajin Cherian <[email protected]>
Cc: Dilip Kumar <[email protected]>
Cc: Nisha Moond <[email protected]>
Cc: Hayato Kuroda (Fujitsu) <[email protected]>
Cc: Bertrand Drouvot <[email protected]>
Cc: Bharath Rupireddy <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Bruce Momjian <[email protected]>
Cc: Ashutosh Sharma <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: pgsql-hackers <[email protected]>
Cc: Alvaro Herrera <[email protected]>
Subject: Re: Synchronizing slots from primary to standby
Date: Sat, 2 Mar 2024 16:24:48 +0530
Message-ID: <CAA4eK1KpFuUPkaFDMXoUOujGVHj4yGWxQ_Xx3DSUU09ieR12Fg@mail.gmail.com> (raw)
In-Reply-To: <OS0PR01MB5716B48653125E199A0901D3945D2@OS0PR01MB5716.jpnprd01.prod.outlook.com>
References: <CAJpy0uBSbBWAWzb2j3OSSGDwhUBZNDAuMWH9B=A9xtVXdOLnCw@mail.gmail.com>
<Zdcqb3Ok+B/[email protected]>
<CAA4eK1KcQSk7wzC7Zfrth9OhrjW2HvxL4tKgU42qqH7p6jn+FA@mail.gmail.com>
<CAA4eK1Lzt6nT6Vrjq+4FEEVE1toK=9sN6vJrGWCziwW-7k8Xpg@mail.gmail.com>
<OS0PR01MB5716E563BFFD591D1F414F4294562@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<OS0PR01MB5716383F68248912EF8D7CE594552@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<OS0PR01MB57161DE4BDB3194C496546A694552@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<OS0PR01MB5716E2CCA142FA07A294D98C94552@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAJpy0uAW3GDeCUuOUqdYQymX3TLyjEKQYLUwG9tUgjYJtZYq2w@mail.gmail.com>
<OS3PR01MB5718FDA975F9694D8BA7B9A794552@OS3PR01MB5718.jpnprd01.prod.outlook.com>
<[email protected]>
<CAA4eK1LnLvM2+-2YfQBk6UHYzdEdNtTuhEunxOO3_n-TqDR0ew@mail.gmail.com>
<OS0PR01MB571654A0288C53A676051AE794592@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+PsGTQb0ijYOfd=x=qX5Aubj=F-pqnfjQ47Jt3MeyBipqA@mail.gmail.com>
<OS0PR01MB57160590C2CBED48976A113B94582@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+Pvqr5wTK3wpcRzSXxiAmBoRa249w0NMjzUOkJg3TTiLCQ@mail.gmail.com>
<CAA4eK1JaHpcS9ZpAGYHSeDQAtLbas55HLqcfnn7n3uWwH-Ko8A@mail.gmail.com>
<CAA4eK1KC9tb0AUKKnkqyuXXc-B89KQDk5NEWxhm15-dPG2pt3g@mail.gmail.com>
<OS0PR01MB5716E281A55E5053DF4976D1945E2@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CAHut+PtDo7LRmAQ4CdR7jSscZBvU7O4rsBSGYobSEPuj-93bXw@mail.gmail.com>
<OS0PR01MB5716B48653125E199A0901D3945D2@OS0PR01MB5716.jpnprd01.prod.outlook.com>
On Sat, Mar 2, 2024 at 9:21 AM Zhijie Hou (Fujitsu)
<[email protected]> wrote:
>
> Apart from the comments, the code in WalSndWaitForWal was refactored
> a bit to make it neater. Thanks Shveta for helping writing the code and doc.
>
A few more comments:
==================
1.
+# Wait until the primary server logs a warning indicating that it is waiting
+# for the sb1_slot to catch up.
+$primary->wait_for_log(
+ qr/replication slot \"sb1_slot\" specified in parameter
standby_slot_names does not have active_pid/,
+ $offset);
Shouldn't we wait for such a LOG even in the first test as well which
involves two standbys and two logical subscribers?
2.
+##################################################
+# Test that logical replication will wait for the user-created inactive
+# physical slot to catch up until we remove the slot from standby_slot_names.
+##################################################
I don't see anything different tested in this test from what we
already tested in the first test involving two standbys and two
logical subscribers. Can you please clarify if I am missing something?
3.
Note that after receiving the shutdown signal, an ERROR
+ * is reported if any slots are dropped, invalidated, or inactive. This
+ * measure is taken to prevent the walsender from waiting indefinitely.
+ */
+ if (NeedToWaitForStandby(target_lsn, flushed_lsn, wait_event))
Isn't this part of the comment should be moved inside NeedToWaitForStandby()?
4.
+ /*
+ * Update our idea of the currently flushed position only if we are
+ * not waiting for standbys to catch up, otherwise the standby would
+ * have to catch up to a newer WAL location in each cycle.
+ */
+ if (wait_event != WAIT_EVENT_WAIT_FOR_STANDBY_CONFIRMATION)
+ {
This functionality (in function WalSndWaitForWal()) seems to ensure
that we first wait for the required WAL to be flushed and then wait
for standbys. If true, we should cover that point in the comments here
or somewhere in the function WalSndWaitForWal().
Apart from this, I have made a few modifications in the comments.
--
With Regards,
Amit Kapila.
diff --git a/src/test/recovery/t/040_standby_failover_slots_sync.pl b/src/test/recovery/t/040_standby_failover_slots_sync.pl
index 5e4dd6c0ab..16483e52a9 100644
--- a/src/test/recovery/t/040_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/040_standby_failover_slots_sync.pl
@@ -505,8 +505,9 @@ ok( $standby1->poll_query_until(
'restart_lsn and confirmed_flush_lsn of slot lsub1_slot synced to standby');
##################################################
-# Test primary disallowing specified logical replication slots getting ahead of
-# specified physical replication slots. It uses the following set up:
+# Test that logical failover replication slots wait for the specified
+# physical replication slots to receive the changes first. It uses the
+# following set up:
#
# (physical standbys)
# | ----> standby1 (primary_slot_name = sb1_slot)
@@ -518,9 +519,9 @@ ok( $standby1->poll_query_until(
#
# standby_slot_names = 'sb1_slot'
#
-# Set up is configured in such a way that the logical slot of subscriber1 is
-# enabled for failover, thus it will wait for the physical slot of
-# standby1(sb1_slot) to catch up before sending decoded changes to subscriber1.
+# The setup is configured in such a way that the logical slot of subscriber1 is
+# enabled for failover, and thus the subscriber1 will wait for the physical
+# slot of standby1(sb1_slot) to catch up before receiving the decoded changes.
##################################################
$backup_name = 'backup3';
@@ -543,8 +544,8 @@ primary_slot_name = 'sb2_slot'
$standby2->start;
$primary->wait_for_replay_catchup($standby2);
-# Configure primary to disallow any logical slots that enabled failover from
-# getting ahead of specified physical replication slot (sb1_slot).
+# Configure primary to disallow any logical slots that have enabled failover
+# from getting ahead of the specified physical replication slot (sb1_slot).
$primary->append_conf(
'postgresql.conf', qq(
standby_slot_names = 'sb1_slot'
Attachments:
[text/plain] v103-0001_amit_1.patch.txt (2.0K, ../CAA4eK1KpFuUPkaFDMXoUOujGVHj4yGWxQ_Xx3DSUU09ieR12Fg@mail.gmail.com/2-v103-0001_amit_1.patch.txt)
download | inline diff:
diff --git a/src/test/recovery/t/040_standby_failover_slots_sync.pl b/src/test/recovery/t/040_standby_failover_slots_sync.pl
index 5e4dd6c0ab..16483e52a9 100644
--- a/src/test/recovery/t/040_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/040_standby_failover_slots_sync.pl
@@ -505,8 +505,9 @@ ok( $standby1->poll_query_until(
'restart_lsn and confirmed_flush_lsn of slot lsub1_slot synced to standby');
##################################################
-# Test primary disallowing specified logical replication slots getting ahead of
-# specified physical replication slots. It uses the following set up:
+# Test that logical failover replication slots wait for the specified
+# physical replication slots to receive the changes first. It uses the
+# following set up:
#
# (physical standbys)
# | ----> standby1 (primary_slot_name = sb1_slot)
@@ -518,9 +519,9 @@ ok( $standby1->poll_query_until(
#
# standby_slot_names = 'sb1_slot'
#
-# Set up is configured in such a way that the logical slot of subscriber1 is
-# enabled for failover, thus it will wait for the physical slot of
-# standby1(sb1_slot) to catch up before sending decoded changes to subscriber1.
+# The setup is configured in such a way that the logical slot of subscriber1 is
+# enabled for failover, and thus the subscriber1 will wait for the physical
+# slot of standby1(sb1_slot) to catch up before receiving the decoded changes.
##################################################
$backup_name = 'backup3';
@@ -543,8 +544,8 @@ primary_slot_name = 'sb2_slot'
$standby2->start;
$primary->wait_for_replay_catchup($standby2);
-# Configure primary to disallow any logical slots that enabled failover from
-# getting ahead of specified physical replication slot (sb1_slot).
+# Configure primary to disallow any logical slots that have enabled failover
+# from getting ahead of the specified physical replication slot (sb1_slot).
$primary->append_conf(
'postgresql.conf', qq(
standby_slot_names = 'sb1_slot'
view thread (68+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Synchronizing slots from primary to standby
In-Reply-To: <CAA4eK1KpFuUPkaFDMXoUOujGVHj4yGWxQ_Xx3DSUU09ieR12Fg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox