On 19 November 2015 at 16:48, konstantin knizhnik <k.knizh...@postgrespro.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