Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node
Date
Msg-id 201206191627.03010.andres@2ndquadrant.com
Whole thread Raw
In response to Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node
List pgsql-hackers
On Tuesday, June 19, 2012 04:17:01 PM Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > On Tuesday, June 19, 2012 08:03:04 AM Tom Lane wrote:
> >> "Every WAL record"?  Why in heck would you attach it to every record?
> >> Surely putting it in WAL page headers would be sufficient.
> > 
> > The idea is that you can have cascading, circular and whatever
> > replication topologies if you include the "logical origin" of a wal
> > causing action into it.
> > That is, if you have nodes A(1) and B(2) and a insert happens on A the
> > wal records generated by that will get an xl_origin_id = 1 and when it
> > will be decoded and replayed on B it will *also* get the id 1. Only when
> > a change originally is generated on Bit will get xl_origin_id = 2.
> 
> None of this explains to me why each individual WAL record would need to
> carry a separate copy of the indicator.  We don't have multiple masters
> putting records into the same WAL file, nor does it seem to me that it
> could possibly be workable to merge WAL streams.  (If you are thinking
> of something sufficiently high-level that merging could possibly work,
> then it's not WAL, and we shouldn't be trying to make the WAL
> representation cater for it.)
The idea is that if youre replaying changes on node A originating from node B 
you set the origin to *B* in the wal records that are generated during that. 
So when B, in a bidirectional setup, replays the changes that A has made it 
can simply ignore all changes which originated on itself.

That works rather simple & performant if you have a conflict avoidance scheme.

For many scenarios you need to be able to separate locally generated changes 
and changes that have been replayed from another node. Without support of 
something like this this is really hard to achieve.

Greetings,

Andres

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


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Do we want a xmalloc or similar function in the Backend?
Next
From: Tom Lane
Date:
Subject: Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node