Re: Proposal: Conflict log history table for Logical Replication

From: vignesh C <vignesh21(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-01-05 15:00:15
Message-ID: CALDaNm2YOOdJ25X1sJ+DYz37K6Qi4g0ZNFHb_pQMF9UqancnEA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2 Jan 2026 at 12:06, shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Fri, Dec 26, 2025 at 8:58 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> >
> > Here is a rebased version of the remaining patches.
> >
>
> Thank You Vignesh. Please find a few comments on 004:
>
>
> 1)
> IIUC, SubscriptionConflictrelIndexId is an unique index on sub-oid and
> conf-relid, but we use it only on relid as key. Why didn't we create
> it only on 'conf-relid' alone? Using a composite unique index is
> guaranteed to give unique row only when all keys are used, but for a
> single key, a unique row is not guaranteed. In our case, it will be a
> unique row as conflict-relid is not shared, but still as an overall
> general concept, it may not be.

As we are searching only on subconflictlogrelid, index on
subconflictlogrelid is sufficient. I have modified it.

> 2)
> IsConflictLogTable():
> + if (OidIsValid(subform->subconflictlogrelid))
>
> Do we need this check? Since we’ve already performed an index access
> using subconflictlogrelid as the key, isn’t it guaranteed to always be
> valid?

It is not required, removed it

> 3)
> Please update the commit message to indicate that this patch makes CLT
> publishable if a publication is explicitly created on it, else few
> changes become very confusing due to unclear intent.

Included this in the commit message.

> 4)
> pg_relation_is_publishable():
>
> /* Subscription conflict log tables are not published */
> - result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple)) &&
> - !IsConflictLogTable(relid);
>
> Comment should be removed too.

Removed

> 5)
> We need to remove below comment:
>
> * Note: Conflict log tables are not publishable. However, we intentionally
> * skip this check here because this function is called for every change and
> * performing this check during every change publication is costly. To ensure
> * unpublishable entries are ignored without incurring performance overhead,
> * tuples inserted into the conflict log table uses the HEAP_INSERT_NO_LOGICAL
> * flag. This allows the decoding layer to bypass these entries automatically.
> */
> bool
> is_publishable_relation(Relation rel)

Removed

> 6)
> get_rel_sync_entry:
> + /* is this relation used for conflict logging? */
> + isconflictlogrel = IsConflictLogTable(relid);
>
> Shall we add a comment indicating the intent of change in this
> function. Something like:
>
> /*
> * Check whether this is a conflict log table. If so, avoid publishing it via
> * FOR ALL TABLES or FOR TABLES IN SCHEMA publications, but still allow it
> * to be published through a publication explicitly created for this table.
> */

Included

The attached v19 patch has the changes for the same.

Regards,
Vignesh

Attachment Content-Type Size
v19-0001-Add-configurable-conflict-log-table-for-Logical-.patch text/x-patch 101.0 KB
v19-0002-Implement-the-conflict-insertion-infrastructure-.patch text/x-patch 33.0 KB
v19-0004-Add-shared-index-for-conflict-log-table-lookup-a.patch text/x-patch 14.1 KB
v19-0003-Doccumentation-patch.patch text/x-patch 11.3 KB
v19-0005-Preserve-conflict-log-destination-and-subscripti.patch text/x-patch 24.3 KB
v19-0006-Allow-combined-conflict_log_destination-settings.patch text/x-patch 58.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-01-05 15:01:44 Reduce build times of pg_trgm GIN indexes
Previous Message Antonin Houska 2026-01-05 14:59:32 Re: Adding REPACK [concurrently]