RE: Conflict detection for update_deleted in logical replication

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Conflict detection for update_deleted in logical replication
Date: 2025-01-23 11:47:05
Message-ID: OS0PR01MB571606EDAB85C69FE233598394E02@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, January 22, 2025 7:54 PM Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> On Saturday, January 18, 2025 11:45 AM Zhijie Hou (Fujitsu)
> <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> > I think invalidating the slot is OK and we could also let the apply
> > worker to automatic recovery as suggested in [1].
> >
> > Here is the V24 patch set. I modified 0004 patch to implement the slot
> > Invalidation part. Since the automatic recovery could be an
> > optimization and the discussion is in progress, I didn't implement that part.
>
> The implementation is in progress and I will include it in next version.
>
> Here is the V25 patch set that includes the following change:
>
> 0001
>
> * Per off-list discussion with Amit, I added few comments to mention the
> reason of skipping advancing xid when table sync is in progress and to mention
> that the advancement will not be delayed if changes are filtered out on
> publisher via row/table filter.
>
> 0004
>
> * Fixed a bug that the launcher would advance the slot.xmin when some apply
> workers have not yet started.
>
> * Fixed a bug that the launcher did not advance the slot.xmin even if one of the
> apply worker has stopped conflict retention due to the lag.
>
> * Add a retain_conflict_info column in the pg_stat_subscription view to
> indicate whether the apply worker is effectively retaining conflict
> information. The value is set to true only if retain_conflict_info is enabled
> for the associated subscription, and the retention duration for conflict
> detection by the apply worker has not exceeded
> max_conflict_retention_duration. Thanks Kuroda-san for contributing codes
> off-list.

Here is V25 patch set which includes the following changes:

0004
* Addressed Nisha's comments[1].
* Fixed a cfbot failure[2] in the doc.

New 0005
* The patch allows the launcher to drop and re-create the invalidated slot, if at
least one apply worker has confirmed that the retention duration is now within
the max_conflict_retention_duration.

[1] https://www.postgresql.org/message-id/CABdArM69ukHVQMmnyKpwbYH8aLhXu-d4fGbSiTkq7BBgRWe0TA%40mail.gmail.com
[2] https://cirrus-ci.com/task/5006366856708096?logs=docs_build#L299

Best Regards,
Hou zj

Attachment Content-Type Size
v26-0006-Add-a-tap-test-to-verify-the-management-of-the-n.patch application/octet-stream 7.0 KB
v26-0007-Support-the-conflict-detection-for-update_delete.patch application/octet-stream 25.7 KB
v26-0001-Maintain-the-oldest-non-removeable-tranasction-I.patch application/octet-stream 41.0 KB
v26-0002-Maintain-the-replication-slot-in-logical-launche.patch application/octet-stream 21.9 KB
v26-0003-Add-a-retain_conflict_info-option-to-subscriptio.patch application/octet-stream 80.1 KB
v26-0004-add-a-max_conflict_retention_duration-subscripti.patch application/octet-stream 90.6 KB
v26-0005-Re-create-the-replication-slot-if-the-conflict-r.patch application/octet-stream 11.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2025-01-23 11:52:18 Re: Virtual generated columns
Previous Message Peter Eisentraut 2025-01-23 11:38:59 Re: Convert macros to static inline functions