RE: Conflict detection for update_deleted in logical replication

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, 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>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Conflict detection for update_deleted in logical replication
Date: 2025-06-25 03:08:33
Message-ID: OS0PR01MB5716416B0966481FAAD944F0947BA@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 24, 2025 at 6:22 PM shveta malik wrote:
>
> On Mon, Jun 23, 2025 at 4:20 PM Zhijie Hou (Fujitsu)
> <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> >
> >
> > Here is the V40 patch set
>
> Thanks for the patches. Few comments:
>
> 1)
> In get_subscription_info(), we are doing COUNT of rci-subscriptions using
> below query:
> SELECT count(*) AS nsub, COUNT(CASE WHEN subretainconflictinfo THEN 1
> END) AS retain_conflict_info FROM pg_catalog.pg_subscription;
>
> And then we are doing:
> cluster->sub_retain_conflict_info = (strcmp(PQgetvalue(res, 0,
> i_retain_conflict_info), "1") == 0);
>
> i.e. get the value and compare with "1". If the count of such subs is say 2,
> won't it fail and will set sub_retain_conflict_info as 0?

Right, it could return wrong results. I have changed it to count(*) xx > 0
so that it can return directly boolean value.

>
> 2)
> create_logical_replication_slots(void)
> {
> + if (!count_old_cluster_logical_slots())
> + return;
> +
>
> We shall get rid of count_old_cluster_logical_slots() here as the caller is
> checking it already.

Removed.

>
> 3)
> We can move the 'old_cluster.sub_retain_conflict_info' check from
> create_conflict_detection_slot() to its caller. Then it will be more informative
> and consistent with how we check migrate_logical_slots outside of
> create_conflict_detection_slot()

Moved.

Here is the V41 patch set which includes the following changes:

0001:
* Rebased due to recent commit fd51941.
* Addressed the comments above.
* Improved some documentation stuff.
* Improved the status message when creating
conflict detection slot in pg_upgrade

0002:
No change

0003:
No change

0004:
No change

0005:
No change

0006:
Rebased due to recent commit fd51941.

Best Regards,
Hou zj

Attachment Content-Type Size
v41-0006-Allow-altering-retain_conflict_info-for-enabled-.patch application/octet-stream 28.5 KB
v41-0001-Retain-the-information-useful-for-detecting-conf.patch application/octet-stream 168.1 KB
v41-0002-Introduce-a-new-GUC-max_conflict_retention_durat.patch application/octet-stream 29.3 KB
v41-0003-Re-create-the-replication-slot-if-the-conflict-r.patch application/octet-stream 7.0 KB
v41-0004-Add-a-tap-test-to-verify-the-management-of-the-n.patch application/octet-stream 8.0 KB
v41-0005-Support-the-conflict-detection-for-update_delete.patch application/octet-stream 29.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-06-25 03:13:25 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2
Previous Message Peter Smith 2025-06-25 02:22:57 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2