From: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
To: Michael Paquier <michael@paquier.xyz>
To: Amit Kapila <akapila@postgresql.org>
Cc: pgsql-committers@lists.postgresql.org <pgsql-committers@lists.postgresql.org>
Subject: RE: pgsql: Preserve conflict-relevant data during logical replication.
Date: Thu, 24 Jul 2025 02:57:10 +0000
Message-ID: <OS0PR01MB571653B3069C781746EFE7FE945EA@OS0PR01MB5716.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <aIGLgfRJIBwExoPj@paquier.xyz>
References: <E1ueQG2-000IEd-0c@gemulon.postgresql.org>
<aIGLgfRJIBwExoPj@paquier.xyz>
On Thursday, July 24, 2025 9:25 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Jul 23, 2025 at 03:35:06AM +0000, Amit Kapila wrote:
> > Preserve conflict-relevant data during logical replication.
> >
> > Logical replication requires reliable conflict detection to maintain
> > data consistency across nodes. To achieve this, we must prevent
> > premature removal of tuples deleted by other origins and their
> > associated commit_ts data by VACUUM, which could otherwise lead to
> > incorrect conflict reporting and resolution.
>
> Some of the tests added by this commit are causing blurps in the CI:
> https://cfbot.cputube.org/highlights/all.html
>
> Example of one job (triggered it once myself with a separate patch):
> https://cirrus-ci.com/task/5397273342902272
> [21:15:03.131](0.028s) not ok 7 - altering retain_dead_tuples is allowed for
> disabled subscription
> [21:18:48.295](225.164s) # poll_query_until timed out executing this
> query:
> [21:18:48.296](0.000s) not ok 8 - the xmin value of slot 'pg_conflict_detection'
> is valid on Node A
> [21:18:48.306](0.010s) not ok 9 - warn of the possibility of receiving changes
> from origins other than the publisher
> [21:18:48.412](0.037s) not ok 11 - the deleted column is non-removable
> [21:22:29.286](220.874s) # poll_query_until timed out executing this
> query:
> [21:22:29.287](0.000s) not ok 12 - the xmin value of slot 'pg_conflict_detection'
> is updated on Node A
> [21:22:29.297](0.010s) not ok 13 - the deleted column is removed
>
> The failures happen on FreeBSD as far as I know, that enforces some rules not
> used elsewhere:
> -c debug_copy_parse_plan_trees=on
> -c debug_write_read_parse_plan_trees=on
> -c debug_raw_expression_coverage_test=on
> -c debug_parallel_query=regress
> [...]
> CPPFLAGS: -DRELCACHE_FORCE_RELEASE
> -DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS
>
> I suspect that reusing these options would help in reproducing the problem.
> These are not commonly used in buildfarm animals, reducing the friction to
> make the instability show up.
Thanks for reporting the issue!
I confirmed that the test to enable the retain_dead_tuples option for a
disabled subscription failed due to the apply worker for that subscription still
running, which caused the all subsequent tests to fail. To resolve this issue,
we need to ensure the apply worker has stopped when disabling the subscription.
> 2025-07-23 21:15:03.128 UTC client backend[39133] 035_conflicts.pl LOG: statement: ALTER SUBSCRIPTION tap_sub_a_b SET (retain_dead_tuples = true);
> 2025-07-23 21:15:03.128 UTC client backend[39133] 035_conflicts.pl ERROR: cannot alter retain_dead_tuples when logical replication worker is still running
Attached is a patch to address this problem. Apart from the reported failure,
there's another place where we did not wait for the worker to stop after
disabling the subscription. Although this hasn't resulted in a test failure so
far, I added wait logic for it in the patch as well for safety.
Best Regards,
Hou zj
Attachments:0001-Fix-Cfbot-failure.patch (application/octet-stream, 1.7K) download
From 15f907b4a980bdad80fae86146b143721854f500 Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@fujitsu.com>
Date: Thu, 24 Jul 2025 10:44:12 +0800
Subject: [PATCH] Fix Cfbot failure
The test failed to enable the retain_dead_tuples option for a disabled
subscription failed due to the apply worker for that subscription still running.
To resolve this issue, ensure the apply worker has stopped after disabling the
subscription.
---
src/test/subscription/t/035_conflicts.pl | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/test/subscription/t/035_conflicts.pl b/src/test/subscription/t/035_conflicts.plindex 7458d7fba7e..976d53a870e 100644--- a/src/test/subscription/t/035_conflicts.pl+++ b/src/test/subscription/t/035_conflicts.pl@@ -228,6 +228,11 @@ ok( $stderr =~
# Disable the subscription
$node_A->psql('postgres', "ALTER SUBSCRIPTION $subname_AB DISABLE;");
+# Wait for the apply worker to stop+$node_A->poll_query_until('postgres',+ "SELECT count(*) = 0 FROM pg_stat_activity WHERE backend_type = 'logical replication apply worker'"+);+
# Enable retain_dead_tuples for disabled subscription
($cmdret, $stdout, $stderr) = $node_A->psql('postgres',
"ALTER SUBSCRIPTION $subname_AB SET (retain_dead_tuples = true);");
@@ -278,6 +283,11 @@ is($result, qq(1|1
# Disable the logical replication from node B to node A
$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB DISABLE");
+# Wait for the apply worker to stop+$node_A->poll_query_until('postgres',+ "SELECT count(*) = 0 FROM pg_stat_activity WHERE backend_type = 'logical replication apply worker'"+);+
$node_B->safe_psql('postgres', "UPDATE tab SET b = 3 WHERE a = 1;");
$node_A->safe_psql('postgres', "DELETE FROM tab WHERE a = 1;");
--
2.50.1.windows.1
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: houzj.fnst@fujitsu.com, michael@paquier.xyz, akapila@postgresql.org
Subject: Re: pgsql: Preserve conflict-relevant data during logical replication.
In-Reply-To: <OS0PR01MB571653B3069C781746EFE7FE945EA@OS0PR01MB5716.jpnprd01.prod.outlook.com>
References: <E1ueQG2-000IEd-0c@gemulon.postgresql.org> <aIGLgfRJIBwExoPj@paquier.xyz> <OS0PR01MB571653B3069C781746EFE7FE945EA@OS0PR01MB5716.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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox