Re: Selective logical replication

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: konstantin knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: Selective logical replication
Date: 2015-11-20 14:03:17
Message-ID: CAMsr+YG=5f-YHs0a6y-mQtmKJK9FHCSFYVec-poEzHHpXzrj4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 19 November 2015 at 16:48, konstantin knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru
> wrote:

> Hi,
>
> I want to use logical replication for implementing multimaster (so all
> nodes are both sending and receiving changes).
>

Like http://bdr-project.org/ ?

> But there is one "stupid" problem: how to prevent infinite recursion and
> not to rereplicate replicated data.
>

You need replication origins, so you can tell where a change came from and
in a mesh topology only send locally-originated tuples to peers.

In a circular forwarding topology you instead filter out a peer's changes
when they come back around the circle to you and forward everything else.

That's exactly what the replication origins feature in 9.5 is for. It lets
you associate a tuple with the node it came from. When doing logical
decoding you can make decisions about whether to forward it based on your
knowledge of the tuple's origin and the peer node(s).

This is trivial to implement this on top of the pglogical output plugin -
we already have the hooks for origin filtering in place. All you have to do
is pass information about which nodes you want to filter out or retain.

See https://github.com/2ndQuadrant/pglogical_output and the unit tests,
especially the hook tests.

> I wonder if there is some better way to prevent some particular
> transaction from been replicated?
>

Replication origins.

http://www.postgresql.org/docs/9.5/static/replication-origins.html

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2015-11-20 14:20:40 Re: Selective logical replication
Previous Message Kouhei Kaigai 2015-11-20 13:45:17 Re: Foreign join pushdown vs EvalPlanQual