RE: Conflict detection for update_deleted in logical replication

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Nisha Moond <nisha(dot)moond412(at)gmail(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 08:31:22
Message-ID: TY4PR01MB1690798295FC14929B238B2DF9432A@TY4PR01MB16907.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thursday, August 21, 2025 3:47 PM Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> 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:
> ...
> 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?

I agree that retentionactive needs to be checked in the cases mentioned above.
Here is the V64 patch set addressing this concern. This version also resolves
the bug reported by Shveta[1], where retention could not resume and was stuck
waiting for the publisher status.

In addition, I also improved the comments related to the new phases and
retentionactive flag.

[1] https://www.postgresql.org/message-id/CAJpy0uCP7x_pdVysYohvrjpk0Vtmk36%2BXfnC_DOPiegekxfBLA%40mail.gmail.com

Best Regards,
Hou zj

Attachment Content-Type Size
v64-0002-Resume-retaining-the-information-for-conflict-de.patch application/octet-stream 17.0 KB
v64-0001-Introduce-a-max_conflict_retention_duration-opti.patch application/octet-stream 112.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 赵宇鹏 (宇彭) 2025-08-21 08:32:48 Re: memory leak in logical WAL sender with pgoutput's cachectx
Previous Message Nisha Moond 2025-08-21 07:46:57 Re: Conflict detection for update_deleted in logical replication