pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <bertranddrouvot.pg@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Cc: Amit Khandekar <amitdkhan.pg@gmail.com>
Cc: fabriziomello@gmail.com, tushar <tushar.ahuja@enterprisedb.com>
Cc: Rahila Syed <rahila.syed@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Minimal logical decoding on standbys
Date: Fri, 7 Apr 2023 08:09:50 +0200
Message-ID: <71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com> (raw)
In-Reply-To: <20230407055618.33gjg5vd5hq3kje4@awork3.anarazel.de>
References: <CAA4eK1L_Zc+7cjm0OhktiPT5xn3=yXn6oenLuEyvJY_CM6T6Mw@mail.gmail.com>
	<e34ab1df-573b-20c1-664a-697851fc736d@gmail.com>
	<CAA4eK1+aUMLu3Q-y6A7nX6kfg_0_6zcRSevWK6Sx6kY1VegCBQ@mail.gmail.com>
	<8c6e7670-3914-35d1-7977-34f60e598477@gmail.com>
	<CAA4eK1+v27a+LONLuRwnzevkp5RuPgsey2VkFB1cfOq2R3XZrA@mail.gmail.com>
	<CAA4eK1+-pdrx3rRD1QCdKcQRaY+B+T3njEXgC3VC3eRAKmDhog@mail.gmail.com>
	<1903ca9b-1dc9-20a6-404a-d4c460c7bdcc@gmail.com>
	<CAA4eK1KFrxgQJt7kc-_o5ruLvafw_FR=NUizA8A7Bp1TDOEj8g@mail.gmail.com>
	<2b002763-f39f-0814-e98e-c48989ddc3c3@gmail.com>
	<3c9d4998-a338-081f-a5f6-d038ead75384@gmail.com>
	<20230407055618.33gjg5vd5hq3kje4@awork3.anarazel.de>

Hi,

On 4/7/23 7:56 AM, Andres Freund wrote:
> Hi,
> 
> On 2023-04-07 07:02:04 +0200, Drouvot, Bertrand wrote:
>> Done in V63 attached and did change the associated comment a bit.
> 
> Can you send your changes incrementally, relative to V62? I'm polishing them
> right now, and that'd make it a lot easier to apply your changes ontop.
> 

Sure, please find them enclosed.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index a4f9a3c972..5b6d19d379 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 67;
+use Test::More;
 
 my ($stdin, $stdout, $stderr, $cascading_stdout, $cascading_stderr, $ret, $handle, $slot);
 
@@ -112,8 +112,7 @@ sub check_slots_dropped
 	check_pg_recvlogical_stderr($slot_user_handle, "conflict with recovery");
 }
 
-# Check if all the slots on standby are dropped. These include the 'activeslot'
-# that was acquired by make_slot_active(), and the non-active 'inactiveslot'.
+# Change hot_standby_feedback and check xmin and catalog_xmin values.
 sub change_hot_standby_feedback_and_wait_for_xmins
 {
 	my ($hsf, $invalidated) = @_;
@@ -560,7 +559,7 @@ ok( find_in_log(
   'activeslot slot invalidation is logged due to wal_level');
 
 # Verify that pg_stat_database_conflicts.confl_active_logicalslot has been updated
-# we now expect 3 conflicts reported as the counter persist across reloads
+# we now expect 4 conflicts reported as the counter persist across reloads
 ok( $node_standby->poll_query_until(
 	'postgres',
 	"select (confl_active_logicalslot = 4) from pg_stat_database_conflicts where datname = 'testdb'", 't'),
@@ -703,3 +702,5 @@ ok( pump_until(
 chomp($cascading_stdout);
 is($cascading_stdout, $expected,
     'got same expected output from pg_recvlogical decoding session on cascading standby');
+
+done_testing();

diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cc4f7b5302..e6427c54c5 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -1945,7 +1945,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
 	 * Indeed, logical walsenders on standby can't decode and send data until
 	 * it's been applied.
 	 *
-	 * Physical walsenders don't need to be wakon up during replay unless
+	 * Physical walsenders don't need to be woken up during replay unless
 	 * cascading replication is allowed and time line change occured (so that
 	 * they can notice that they are on a new time line).
 	 *
@@ -1953,9 +1953,11 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
 	 *
 	 *  - physical walsenders in case of new time line and cascade
 	 *  replication is allowed.
-	 *  - always true for logical walsenders.
+	 *  - logical walsenders in case cascade replication is allowed (could not
+	 *  be created otherwise).
 	 */
-	WalSndWakeup(switchedTLI && AllowCascadeReplication(), true);
+	if (AllowCascadeReplication())
+		WalSndWakeup(switchedTLI, true);
 
 	/*
 	 * If rm_redo called XLogRequestWalReceiverReply, then we wake up the


Attachments:

  [text/plain] v62-63-0005-New-TAP-test-for-logical-decoding-on-standby.patch (1.6K, ../71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com/2-v62-63-0005-New-TAP-test-for-logical-decoding-on-standby.patch)
  download | inline diff:
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index a4f9a3c972..5b6d19d379 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 67;
+use Test::More;
 
 my ($stdin, $stdout, $stderr, $cascading_stdout, $cascading_stderr, $ret, $handle, $slot);
 
@@ -112,8 +112,7 @@ sub check_slots_dropped
 	check_pg_recvlogical_stderr($slot_user_handle, "conflict with recovery");
 }
 
-# Check if all the slots on standby are dropped. These include the 'activeslot'
-# that was acquired by make_slot_active(), and the non-active 'inactiveslot'.
+# Change hot_standby_feedback and check xmin and catalog_xmin values.
 sub change_hot_standby_feedback_and_wait_for_xmins
 {
 	my ($hsf, $invalidated) = @_;
@@ -560,7 +559,7 @@ ok( find_in_log(
   'activeslot slot invalidation is logged due to wal_level');
 
 # Verify that pg_stat_database_conflicts.confl_active_logicalslot has been updated
-# we now expect 3 conflicts reported as the counter persist across reloads
+# we now expect 4 conflicts reported as the counter persist across reloads
 ok( $node_standby->poll_query_until(
 	'postgres',
 	"select (confl_active_logicalslot = 4) from pg_stat_database_conflicts where datname = 'testdb'", 't'),
@@ -703,3 +702,5 @@ ok( pump_until(
 chomp($cascading_stdout);
 is($cascading_stdout, $expected,
     'got same expected output from pg_recvlogical decoding session on cascading standby');
+
+done_testing();


  [text/plain] v62-63-0004-For-cascading-replication-wake-up-physical-walse.patch (1.3K, ../71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com/3-v62-63-0004-For-cascading-replication-wake-up-physical-walse.patch)
  download | inline diff:
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cc4f7b5302..e6427c54c5 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -1945,7 +1945,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
 	 * Indeed, logical walsenders on standby can't decode and send data until
 	 * it's been applied.
 	 *
-	 * Physical walsenders don't need to be wakon up during replay unless
+	 * Physical walsenders don't need to be woken up during replay unless
 	 * cascading replication is allowed and time line change occured (so that
 	 * they can notice that they are on a new time line).
 	 *
@@ -1953,9 +1953,11 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
 	 *
 	 *  - physical walsenders in case of new time line and cascade
 	 *  replication is allowed.
-	 *  - always true for logical walsenders.
+	 *  - logical walsenders in case cascade replication is allowed (could not
+	 *  be created otherwise).
 	 */
-	WalSndWakeup(switchedTLI && AllowCascadeReplication(), true);
+	if (AllowCascadeReplication())
+		WalSndWakeup(switchedTLI, true);
 
 	/*
 	 * If rm_redo called XLogRequestWalReceiverReply, then we wake up the


view thread (361+ messages)  latest in thread

Message-ID: <71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com>
Permalink:  ../71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com/
Also on:    postgresql.org/message-id/71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@gmail.com

 ·  · 

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: pgsql-hackers@postgresql.org
  Cc: bertranddrouvot.pg@gmail.com, andres@anarazel.de, amit.kapila16@gmail.com, alvherre@alvh.no-ip.org, pgsql@j-davis.com, robertmhaas@gmail.com, thomas.munro@gmail.com, ibrar.ahmad@gmail.com, amitdkhan.pg@gmail.com, tushar.ahuja@enterprisedb.com, rahila.syed@2ndquadrant.com
  Subject: Re: Minimal logical decoding on standbys
  In-Reply-To: <71c3d91a-6b3b-5c0a-ffb9-630f17fe693e@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox