Re: Conflict detection for update_deleted in logical replication

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Conflict detection for update_deleted in logical replication
Date: 2025-08-21 07:46:57
Message-ID: CABdArM6ySTjbq3XmrcDxC-TkNAWSuP8iB5n7PTtGvzvA8+LDxg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 20, 2025 at 12:12 PM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> I agree. Here is V63 version which implements this approach.
>

Thank you Hou-san for the patches. Here are couple of comments:

1) Once retention is stopped for all subscriptions and
conflict_slot.xmin is reset to NULL, we are no longer retaining dead
tuples. In that case, the warning shown during subscription disable
looks misleading.

For example sub has already stopped the retention and when disabled -
postgres=# alter subscription sub1 disable;
WARNING: deleted rows to detect conflicts would not be removed until
the subscription is enabled
HINT: Consider setting retain_dead_tuples to false.
ALTER SUBSCRIPTION

I think we should check if retention is active or not here.

2) Regarding the logic in the launcher for advancing the slot’s xmin:
Consider a case where two subscriptions exist, and one of them is
disabled after it has already stopped retention.
Example subscriptions in state:
subname | subenabled | subretaindeadtuples | submaxconflretention |
subretentionactive
---------+------------+---------------------+----------------------+--------------------
sub1 | t | t | 100 | t
sub2 | f | t | 100 | f

Here, sub2 is disabled, and since subretentionactive = 'f', it is not
retaining dead tuples anymore. But, the current launcher logic still
blocks xmin advancement as one of the subscriptions with
retain_dead_tuples is disabled.
I think the launcher should consider the subretentionactive value and
the xmin should be allowed to advance. Thoughts?

--
Thanks,
Nisha

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-08-21 08:31:22 RE: Conflict detection for update_deleted in logical replication
Previous Message Peter Eisentraut 2025-08-21 07:46:16 Re: event trigger support for PL/Python