Re: Proposal: Conflict log history table for Logical Replication

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, saurabh singh <saurabh(dot)singh214(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(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-08-10 13:15:15
Message-ID: CAFiTN-su6+fvQWtHWOvq3X0QZ7mvzcyR4OdkGewS=oh0tni60A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 10, 2026 at 10:32 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Sat, Aug 8, 2026 at 2:23 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> >
> > There are two possible definitions we could give to CLT:
> >
> > 1. it stores how replication conflicts were resolved.
> > 2. it stores which replication conflicts caused data divergences (and
> > how they were resolved).
> >
> > My interpretation had been (1). The option is named
> > conflict_log_destination, which reads as choosing where the same
> > information goes, and the server log carries every conflict including
> > the conflicts resolved by the ERROR resolver. So I expected the table
> > to have the same coverage.
> >
> > That said, I can accept (2), and I agree it is what other replication
> > solutions do. If we go that way, though, I would like the CLT to have
> > a 'resolution' column, showing which resolution method was applied,
> > even though the resolvers are hard-wired per conflict type today. With
> > that column, a user can see both what conflict happened and how it was
> > handled by looking at the CLT alone.

Here is an updated patch as we discussed, and below is the list of changes:

1. Insert only resolved (LOG-level) conflicts in the conflict log
table: Conflicts that raise an ERROR halt replication and roll back
the transaction, so they are logged exclusively to the server log for
monitoring and alerting. The table is preserved purely as an audit log
for resolved conflicts where data is updated or skipped, I updated the
documentation accordingly.

2. Removed the key column from LocalConflictSchema: Since unique index
violations are ERROR-level and no longer stored in the table, the key
attribute is unnecessary and has been removed.

3. Preserved local_conflicts as json[]: Although currently recorded
conflicts involve a single local tuple, we decided to keep
local_conflicts as a JSON array for future-proofing. This ensures that
any future enhancements (such as multi-row conflict resolvers) will
not require backward-incompatible table schema changes.

I will work on other follow-up patches soon.

--
Regards,
Dilip Kumar
Google

Attachment Content-Type Size
v67-0001-Implement-the-conflict-insertion-infrastructure-.patch application/octet-stream 74.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-08-10 13:30:19 Re: pg_control_checkpoint(): add "data_checksum_version" (Pg19)?
Previous Message Ayush Tiwari 2026-08-10 12:40:30 Re: Error handling in after-startup shmem requests