Re: unidirectional logical replication logging issue

From: Fabrice Chapuis <commeilmeplait(at)gmail(dot)com>
To: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: unidirectional logical replication logging issue
Date: 2026-11-24 11:16:18
Message-ID: CADmBQcPAsZpa2eFZ8SC02b+hMbLA4xDgUmsCJTVAAFCit7BbHQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Nisha,

Thanks for your detailed explanation and for pointing me to the ongoing
discussion about conflict_log_destination.

I understand that disabling track_commit_timestamp would prevent these
origin conflicts from being detected. However, I would prefer to keep it
enabled, as it provides useful information beyond logical replication
conflict detection.

My concern is specifically about the volume of log messages generated by
non-blocking conflicts such as update_origin_differs and
delete_origin_differs.

In our environment, after reloading millions of rows on the subscriber, a
large UPDATE on the publisher can generate millions of LOG messages, even
though replication continues successfully.

Would it make sense to introduce a new GUC, for example:

log_logical_replication_origin_conflicts = on | off

The default would be on to preserve the current behavior.

Setting it to off would suppress LOG messages for update_origin_differs and
delete_origin_differs, while keeping conflict detection and the associated
statistics enabled. Other replication conflicts, especially those causing
replication to stop, would continue to be logged.

Here is a resume:

Behavior

GUC on

GUC off

Detect origin conflicts

Yes

Yes

Apply incoming UPDATE/DELETE

Yes

Yes

Increment conflict statistics

Yes

Yes

Write origin conflict LOG messages

Yes

No

Report replication-blocking errors

Yes

Yes

I think separating conflict detection from logging would be useful for
environments with large datasets where these non-blocking conflicts are
expected and do not require intervention.

Would you consider this a reasonable approach?

Best regards,
Fabrice

On Tue, 24 Nov 2026 at 07:57, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:

> On Mon, Nov 23, 2026 at 10:21 PM Fabrice Chapuis
> <commeilmeplait(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > After upgrading to PostgreSQL 18, we started seeing numerous
> update_origin_differs messages in the PostgreSQL logs for a unidirectional
> logical replication setup.
> >
>
> Hi Fabrice,
>
> Thanks for the report. I see there are two different cases here.
>
> > Our configuration is relatively simple:
> >
> > One publisher and one subscriber.
> >
> > Both databases are on the same PostgreSQL instance.
> >
> > The subscription is configured with origin = 'any'.
> >
> > track_commit_timestamp = on.
> >
> > The subscriber is not supposed to receive direct application updates.
> >
> > Example:
> >
> > LOG: conflict detected on relation "public.table1":
> > conflict=update_origin_differs
> > DETAIL: Updating the row that was modified locally
> > in transaction 478887529
> > at 2026-10-15 10:36:16.753439+02.
> > CONTEXT: processing remote data for replication origin "pg_139879339"
> > during message type "UPDATE"
> >
> > We did not observe these messages in PostgreSQL 17, as conflict logging
> was introduced in PostgreSQL 18.
> >
> > The replication continues working normally, but these messages can
> generate a significant amount of log data, particularly because the DETAIL
> includes the full local and remote rows.
> > This can lead to the filesystem becoming completely full.
> >
> > My use case is this one:
> > I stop logical replication and reload data in source table and in
> destination table, then I reactivate logical replication. The table
> contains million of rows.
> > when massive update are executed on the source table, messages fill the
> postgres log.
> >
> > It seems there is no easy way to disable logging specifically without
> disabling track_commit_timestamp
> >
>
> Rows loaded by a local session on the subscriber have no replication
> origin. When the publisher later updates them, the apply worker sees
> that the local row came from a different origin (local/NONE) and
> reports update_origin_differs.
> This is what the check is meant to do. From the subscriber's point of
> view, these rows were modified locally. It's reported once per row, so
> after a reload of millions of rows, the first large UPDATE logs one
> message per row.
>
> > The same behaviour is observer with copy_data = true
> >
>
> This is a known issue and is being discussed in [1]. The initial table
> sync copies the rows under its own replication origin
> (pg_<subid>_<relid>), but the apply worker later applies changes under
> the subscription's origin (pg_<subid>). So for every copied row the
> origins differ, and the first UPDATE or DELETE of each one is reported
> as update/delete_origin_differs, even though the data came from the
> same publisher.
>
> > Would it make sense to introduce a configuration parameter to control
> the logging of these non-blocking conflicts?
> >
>
> A new subscription option, conflict_log_destination [2], to store
> conflict details in a table is under development. A short LOG line is
> still written for each conflict, though, so it reduces the log volume
> but doesn't remove it.
>
> I don't mind discussing a separate setting for logging these
> conflicts. But I'm not sure it's needed, since track_commit_timestamp
> already controls whether these conflicts are detected at all.
>
> [1]
> https://www.postgresql.org/message-id/19360-1952ab7afd799f70%40postgresql.org
> [2]
> https://www.postgresql.org/message-id/flat/CAFiTN-u5D5o_AGNbHRZHaOqAMWkxLf%2BhSk_r9X3gv6HbLOB5%2Bg%40mail.gmail.com
>
> --
> Thanks,
> Nisha
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-11-24 11:45:39 Re: BUG #19631: currtid2() on a view with GROUP BY ctid crashes with XX000
Previous Message shveta malik 2026-11-24 10:36:03 Re: [PATCH] Report changes discarded for relations not in the subscription