public inbox for [email protected]  
help / color / mirror / Atom feed
From: Hayato Kuroda (Fujitsu) <[email protected]>
To: 'Amit Kapila' <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Cc: Zhijie Hou (Fujitsu) <[email protected]>
Cc: Masahiko Sawada <[email protected]>
Subject: RE: Selectively invalidate caches in pgoutput module
Date: Fri, 28 Mar 2025 05:16:29 +0000
Message-ID: <OSCPR01MB149661933DF061B6A9C2E0804F5A02@OSCPR01MB14966.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAA4eK1LnDhA+x5LY8WY-Un6aG=K9mvXMB0FTrf17hiAmkUNUdA@mail.gmail.com>
References: <OSCPR01MB149669AF61681064D2A75FAE9F5D42@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<OSCPR01MB1496609BD298A6660B1F8AF28F5D62@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<OSCPR01MB14966B4602D103050DC91837DF5D62@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<OS3PR01MB5718B8EFFBB856C8B5749E8B94D62@OS3PR01MB5718.jpnprd01.prod.outlook.com>
	<OSCPR01MB14966DBBE4666C701FB8943E0F5D62@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<TYAPR01MB5724414167645263B733A86394D12@TYAPR01MB5724.jpnprd01.prod.outlook.com>
	<OSCPR01MB149665015BC2F5DC260E4E184F5D12@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<CAA4eK1LjLLx9+w4FKHOma9-276-txZW8fLSvabLsvh5DLVHBug@mail.gmail.com>
	<OSCPR01MB1496634BCDF6475BF0AC6658BF5D02@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<CAA4eK1+fDhZ4xaxxO=Hh8==uQCz89qD5d-82pcF+rbBpO_2O-w@mail.gmail.com>
	<ksxbayuk5hgqdsryjxqkbnjyvk6amd2jf5tui565ex6vazglls@jva4njirno4u>
	<OSCPR01MB149665CDC1E300EC4CA9C5FA7F5A02@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<CAA4eK1LnDhA+x5LY8WY-Un6aG=K9mvXMB0FTrf17hiAmkUNUdA@mail.gmail.com>

Dear Amit,

> The problem here is that after ALTER SUBSCRIPTION tap_sub SET
> PUBLICATION ..., we didn't wait for the new walsender on publisher to
> start. We must use wait_for_subscription_sync both after the "CREATE
> SUBSCRIPTION ..." and the "ALTER SUBSCRIPTION ..." commands and keep
> copy_data=true to ensure the initial replication is setup between
> publisher and subscriber. This is how we use these commands at other
> places.

Agreed. PSA the patch to fix the issue.

Best regards,
Hayato Kuroda
FUJITSU LIMITED



Attachments:

  [application/octet-stream] 0001-Stablize-tests-added-in-3abe9dc188.patch (2.2K, ../OSCPR01MB149661933DF061B6A9C2E0804F5A02@OSCPR01MB14966.jpnprd01.prod.outlook.com/2-0001-Stablize-tests-added-in-3abe9dc188.patch)
  download | inline diff:
From 67c9a2c1a83c94b9c30454592b6b498f9bfbd41f Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <[email protected]>
Date: Fri, 28 Mar 2025 14:02:29 +0900
Subject: [PATCH] Stablize tests added in 3abe9dc188.

The problem is that after the ALTER SUBSCRIPTION tap_sub SET PUBLICATION
command, we didn't wait for the new walsender to start on the publisher.
Immediately after ALTER, we performed Insert and expected it to replicate.
However, the replication could start from a point after the INSERT location,
and as the subscription isn't copying initial data, we could miss such an
Insert.

The fix is to wait for connection to be established between publisher and
subscriber before starting DML operations that are expected to replicate.

As per CI.

Reported-by: Andres Freund <[email protected]>
Author: Hayato Kuroda <[email protected]>
Discussion: https://postgr.es/m/CALDaNm2ms1deM5EYNLFEfESv_Kw=Y4AiTB0LP=qGS-UpFwGbPg@mail.gmail.com
---
 src/test/subscription/t/007_ddl.pl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/test/subscription/t/007_ddl.pl b/src/test/subscription/t/007_ddl.pl
index 7d4c2d51c3a..36f1817ece6 100644
--- a/src/test/subscription/t/007_ddl.pl
+++ b/src/test/subscription/t/007_ddl.pl
@@ -130,16 +130,18 @@ $node_publisher->safe_psql('postgres', qq[
 	CREATE PUBLICATION pub_for_all_tables FOR ALL TABLES;
 ]);
 $node_subscriber->safe_psql('postgres',
-	"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION pub_for_tab WITH (copy_data = off)"
+	"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION pub_for_tab"
 );
+$node_subscriber->wait_for_subscription_sync;
 
 # Confirms RENAME command works well for a publication
 test_swap('test1', 'pub_for_tab', 'tap_sub');
 
 # Switches a publication which includes all tables
 $node_subscriber->safe_psql('postgres',
-	"ALTER SUBSCRIPTION tap_sub SET PUBLICATION pub_for_all_tables WITH (refresh = true, copy_data = false);"
+	"ALTER SUBSCRIPTION tap_sub SET PUBLICATION pub_for_all_tables;"
 );
+$node_subscriber->wait_for_subscription_sync;
 
 # Confirms RENAME command works well for ALL TABLES publication
 test_swap('test2', 'pub_for_all_tables', 'tap_sub');
-- 
2.43.5



view thread (23+ 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]
  Subject: RE: Selectively invalidate caches in pgoutput module
  In-Reply-To: <OSCPR01MB149661933DF061B6A9C2E0804F5A02@OSCPR01MB14966.jpnprd01.prod.outlook.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