Re: BUG #19360: Bug Report: Logical Replication initial sync fails with "conflict=update_origin_differs" PG12 toPG18 - Mailing list pgsql-bugs

From Masahiko Sawada
Subject Re: BUG #19360: Bug Report: Logical Replication initial sync fails with "conflict=update_origin_differs" PG12 toPG18
Date
Msg-id CAD21AoCRReJHoLkQBMZztjO7C3Cste9w-PS_SG7VtBW1c3cR9w@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19360: Bug Report: Logical Replication initial sync fails with "conflict=update_origin_differs" PG12 toPG18  (Dilip Kumar <dilipbalaut@gmail.com>)
List pgsql-bugs
On Thu, Jan 8, 2026 at 8:46 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
>
> On Fri, Jan 9, 2026 at 4:17 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > On Mon, Dec 29, 2025 at 10:55 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> > >
> > > On Mon, Dec 29, 2025 at 4:26 PM vignesh C <vignesh21@gmail.com> wrote:
> > > >
> > > > On Mon, 22 Dec 2025 at 19:00, PG Bug reporting form
> > > > <noreply@postgresql.org> wrote:
> > > > >
> > > >
> > > > This can occur in the following scenario: commit timestamp tracking is
> > > > enabled on the subscriber; the same table exists on both publisher and
> > > > subscriber; a publication is created on the publisher with initial
> > > > data; and a subscription is created on the subscriber with origin =
> > > > none. During the initial table synchronization, the row is inserted
> > > > using a tablesync replication origin, which is dropped once
> > > > synchronization completes. If the row is updated on the publisher
> > > > after the initial sync, the apply worker attempts to update a row that
> > > > was inserted using a different replication origin(tablesync origin),
> > > > resulting in an origin mismatch.
> > > >
> > > > The conflict is logged and logical replication continues normally. No
> > > > crash occurs, and the log entry is informational rather than
> > > > indicative of a failure.
> > > >
> > >
> > > I agree with this analysis.
> > >
> > > > These messages can be safely ignored for now.
> > > >
> > > > We are currently evaluating possible improvements to handle this
> > > > scenario more gracefully and to avoid reporting these conflicts in the
> > > > future.
> > > >
> > >
> > > One idea to safely ignore these LOGs is we could modify the state
> > > management in the catalog pg_subscription_rel to store originID. When
> > > a tablesync worker completes, instead of just deleting the origin and
> > > setting the relation state to ready, it could record the origin_id it
> > > used into pg_subscription_rel.  When the apply worker encounters an
> > > origin mismatch, it checks pg_subscription_rel for that specific
> > > table. If the "old" origin ID matches the one recorded during the sync
> > > phase, the worker knows the row is "ours" and suppresses the log. Now,
> > > as the origin ID could be reused, we could additionally store local
> > > timestamp along with originId in pg_subscription_rel. Then, we can
> > > suppress the log if: row_origin_id == srsuboriginid AND
> > > row_commit_time <= srsubsynctime.
> >
> > It sounds very costly. IIUC we would need these checks for every first
> > update to tuples loaded via initial table sync. Can we somehow share
> > the apply worker's origin with tablesync workers so that they can
> > refer to the same origin ID? Or can we invent special origin IDs
> > (e.g., > 0x00FF) that are the same as the normal origin ID except for
> > being ignored by the conflict detection system?
>
> How will this distinguish between the initial sync is done from the
> publisher node we are getting the update vs the initial sync is done
> from some other node?  Can we always ignore conflict checking for
> initial synced data or do we just want to ignore if the  initial sync
> is done from the same node?

I imagined the former idea; always ignore conflict checking, so we
don't need to distinguish them. IOW we treat the changes via the
initial tablesync as if the changes made by the normal backend process
(who doesn't use replication origin) while using the replication
tracking ability of the replication origin.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com



pgsql-bugs by date:

Previous
From: Paveł Tyślacki
Date:
Subject: Re: BUG #19365: postgres 18 pg_dump fails whan drop sequence concurrently