Re: Logical Replication WIP

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Erik Rijkers <er(at)xs4all(dot)nl>, Steve Singer <steve(at)ssinger(dot)info>, pgsql-hackers-owner(at)postgresql(dot)org, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Logical Replication WIP
Date: 2016-12-15 14:06:59
Message-ID: ca14e246-b3b1-3e58-2eab-106d9fd6b7af@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15/12/16 13:06, Craig Ringer wrote:
> On 15 Dec. 2016 18:19, "Petr Jelinek" <petr(dot)jelinek(at)2ndquadrant(dot)com
> <mailto:petr(dot)jelinek(at)2ndquadrant(dot)com>> wrote:
>
> On 13/12/16 21:42, Peter Eisentraut wrote:
> > On 12/10/16 2:48 AM, Petr Jelinek wrote:
> >> Attached new version with your updates and rebased on top of the
> current
> >> HEAD (the partitioning patch produced quite a few conflicts).
> >
> > I have attached a few more "fixup" patches, mostly with some
> editing of
> > documentation and comments and some compiler warnings.
> >
> > In 0006 in the protocol documentation I have left a "XXX ???" where I
> > didn't understand what it was trying to say.
> >
>
> Ah so you didn't understand the
> > + Identifies the following TupleData submessage as
> a key.
> > + This field is optional and is only present if
> > + the update changed the REPLICA IDENTITY index. XXX???
>
> So what happens here is that the update message can contain one or two
> out of 3 possible tuple submessages. It always contains 'N' message
> which is the new data. Then it can optionally contain 'O' message with
> old data if the table has REPLICA IDENTITY FULL (ie, not REPLICA
> IDENTITY index like pkey, etc). Or it can include 'K' message that only
> contains old data for the columns in the REPLICA IDENTITY index. But if
> the REPLICA IDENTITY index didn't change (ie, old and new would be same
> for those columns) we simply omit the 'K' message and let the downstream
> take the key data from the 'N' message to save space.
>
>
> Something we forgot to bake into pglogical that might be worth leaving
> room for here: sending the whole old tuple, with some fields marked as key.
>
> So you can use replica identity pkey or whatever and the downstream
> knows which are the key fields. But can still transmit the whole old
> tuple in case the downstream wants it for conflict resolution/logging/etc.
>
> We don't have the logical decoding and wal output for this yet, nor a
> way of requesting old tuple recording table by table. So all i'm
> suggesting is leaving room in the protocol.
>

Not really sure I follow, which columns are keys is not part of the info
in the data message, it's part of relation message, so it's already
possible in the protocol. Also the current implementation is fully
capable of taking advantage of PK on downstream even with REPLICA
IDENTITY FULL.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-12-15 14:36:06 Re: proposal: session server side variables
Previous Message Kevin Grittner 2016-12-15 14:01:12 Re: [OSSTEST PATCH 0/1] PostgreSQL db: Retry on constraint violation [and 2 more messages] [and 1 more messages]