Re: [PATCH] Fix replica identity mismatch for partitioned tables with publish_via_partition_root

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: jihyun bahn <rring0727(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Mikhail Kharitonov <mikhail(dot)kharitonov(dot)dev(at)gmail(dot)com>
Subject: Re: [PATCH] Fix replica identity mismatch for partitioned tables with publish_via_partition_root
Date: 2026-08-02 20:43:39
Message-ID: CAPpHfds-NTdAMqy1+8i07WBoMDM9agr9773Xy2hsQquZEwedEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI!

On Wed, Jun 17, 2026 at 10:54 AM jihyun bahn <rring0727(at)gmail(dot)com> wrote:
> On the deeper issue
> -------------------
> The native divergence comes from the old tuple carrying a NULL for a
> column that the subscriber -- told the relation is REPLICA IDENTITY
> FULL, from the root -- then compares as a real value. I tried a small
> experiment: a new per-column wire marker meaning "this column is not
> part of the replica identity and was not sent", emitted under a new
> protocol version for the columns outside the leaf's replica identity.
> The subscriber excludes those columns from old-tuple matching, reusing
> the same per-column exclusion that RelationFindDeletedTupleInfoSeq()
> already does for conflict detection. With that, the no-index
> subscriber above matches the c2 DELETE by key and the divergence
> disappears, while older subscribers fall back to today's behavior. It
> does not touch the Relation message.
>
> I am not proposing that here -- it is a rough prototype and larger
> than this patch's scope. But I wanted to ask: is a direction
> like that of interest as a separate patch, or is a root/leaf
> replica-identity mismatch under publish_via_partition_root considered a
> misconfiguration that should instead be warned about at publication
> time? I could not find the heterogeneous-RI case settled either way in
> the archives -- a 2019 thread from Alvaro, "propagating replica
> identity to partitions", explored making it propagate, but as far as I
> can tell that did not end in a committed change (replica identity still
> does not cascade to partitions today). So I am unsure which way the
> project leans.

Indeed, publish_via_partition_root makes leaf to publish its changes
via root, but we don't force root and leaf identities to match. Let
me try to address both issues.

0001 New version of patch which makes leaf old-tuple's tag match its
contents. Revised according to my notes in [1].
0002 This patch rejects DDL configuration where leaf's replica
identity doesn't cover root's replica identity when
publish_via_partition_root == true. It's enforced in four DDL points:
CREATE PUBLICATION, ALTER PUBLICATION SET, ATTACH PARTITION, ALTER
TABLE REPLICA IDENTITY. NOTHING is covered by everything, FULL is
covered only by FULL, otherwise leaf's identity columns set must cover
corresponding root's set.

I'm curious about the feedback, especially on the approach of 0002.

Links
1. https://www.postgresql.org/message-id/CAPpHfdvjDfaPvJvfo7LjFgZNuBXUvWp8OyaU6-Aksrj-whocJA%40mail.gmail.com

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v4-0001-logical-replication-make-old_tuple-s-flag-match-i.patch application/octet-stream 16.1 KB
v4-0002-Enforce-leaf-root-replica-identity-coverage-under.patch application/octet-stream 35.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-08-02 23:21:19 Re: Bug: XLogReader mishandles oversized multi-page xl_tot_len (potential memory corruption)
Previous Message Alexander Korotkov 2026-08-02 20:11:50 Re: GiST multirange index scans can fail to return rows