Re: Conflict Detection and Resolution

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: jmajoor(at)sparklinglogic(dot)com
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>, Diego Fronza <diego(dot)fronza(at)percona(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>, Ajin Cherian <itsajin(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Zhijie Hou <houzhijie22(at)gmail(dot)com>
Subject: Re: Conflict Detection and Resolution
Date: 2026-11-26 10:46:34
Message-ID: CABdArM5qLEY60jC7t-XorE1zXWTRi3-DvsvD8Zd2MSXD=Bk-Hw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 24, 2026 at 10:56 PM <jmajoor(at)sparklinglogic(dot)com> wrote:
>
> Thanks for the reply.
>
> The term "full" is indeed not very helpful.
> In my particular case I am not interested in DDL.

Thanks a lot for explaining your setup in detail.
IIUC, these points are separate from the conflict resolution work
discussed in this thread, which is about resolving conflicts while
applying replicated changes. I think, each of them is an improvement
worth discussing on its own.

> Currently using pglogical, but there are limitations to their approach. It is easy to get into a circular replication loop, which can only be broken by using the forward-origin setting. However, that doesn't allow for some replication scenarios. If I have 2 regions east and west and in each region you have 2 instances. E1 and E2 are bi-directional and to prevent a loop E2 can get everything from E1, but E1 can only get local origin from E2 (same for W1, W2). If you connect E1 and W1 together, then the changes on E2 and W2 are not replicated into all instances due to the forward origin settings.
>

Core logical replication has a similar option, origin = none, which
publishes only changes made locally on the publisher. So it has the
same limitation in your topology: E2's changes reach E1, but E1 does
not forward them to W1. Today, getting all changes to all four
instances can be done with a full mesh, where each instance subscribes
directly to every other instance with origin = none. In your setup:

- E1 subscribes to E2, W1 and W2
- E2 subscribes to E1, W1 and W2
- W1 subscribes to E1, E2 and W2
- W2 subscribes to E1, E2 and W1

Each instance publishes its tables once, and the other three subscribe
to that publication. A change made on E2 is then sent by E2 directly
to E1, W1 and W2. Because every subscription uses origin = none, none
of them forwards it any further, so there are no loops. Smarter
forwarding, e.g. filtering by a list of origins, would be a separate
feature.

> Another limitation is the initial data sync, since that is just a bulk copy it doesn't apply any conflict rules and this forces you to basically delete everything followed by a data sync and replication.
>

Right, the initial sync is a bulk copy, so no conflict rules apply to
it. Handling conflicts during the copy, so that it can work against
existing data, would extend the resolution work to table sync. If the
data on both sides is already the same, copy_data = false avoids the
full copy.

> Lastly if you unsubscribe and at a later point re-subscribe, then pglogical can not replicate from the last known replication point and requires a full delete/data sync/replication again. This may not be as important.
>

I think this is already supported in core. If you disable the
subscription (ALTER SUBSCRIPTION ... DISABLE) and enable it later,
replication resumes from where it stopped, as long as the subscription
and its slot on the publisher are kept. The cost is that the slot
holds back WAL on the publisher while the subscription is disabled, so
max_slot_wal_keep_size, or idle_replication_slot_timeout if set, can
invalidate the slot during a long pause.

--
Thanks,
Nisha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-11-26 10:50:34 Re: Add counted_by attribute
Previous Message Raja Sai pranav 2026-11-26 10:31:53 Re: Proposal: Conflict log history table for Logical Replication