Logical Replication Helpers WIP for discussion

Lists: pgsql-hackers
From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: ">> PostgreSQL-development" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Logical Replication Helpers WIP for discussion
Date: 2014-12-15 05:57:48
Message-ID: 548E785C.2080904@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

we've made few helper functions for making logical replication easier, I
bundled it into contrib module as this is mainly for discussion at this
time (I don't expect this to get committed any time soon, but it is good
way to iron out protocol, etc).

I created sample logical decoding plugin that uses those functions and
which can be used for passing DML changes in platform/version
independent (hopefully) format.

I will post sample apply BG worker also once I get some initial feedback
about this.

It's hard to write tests for this as the binary changes contain
transaction ids and timestamps so the data changes constantly.

This is of course based on the BDR work Andres, Craig and myself have
been doing.

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

Attachment Content-Type Size
lrep-v0.patch text/x-diff 37.1 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2014-12-15 18:42:51
Message-ID: CA+TgmoZmHd1T3m_Aa2y4wDCZ_WEBCrA+JeyW9BxGsDaFU7278Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 15, 2014 at 12:57 AM, Petr Jelinek <petr(at)2ndquadrant(dot)com> wrote:
> we've made few helper functions for making logical replication easier, I
> bundled it into contrib module as this is mainly for discussion at this time
> (I don't expect this to get committed any time soon, but it is good way to
> iron out protocol, etc).
>
> I created sample logical decoding plugin that uses those functions and which
> can be used for passing DML changes in platform/version independent
> (hopefully) format.
>
> I will post sample apply BG worker also once I get some initial feedback
> about this.
>
> It's hard to write tests for this as the binary changes contain transaction
> ids and timestamps so the data changes constantly.
>
> This is of course based on the BDR work Andres, Craig and myself have been
> doing.

I can't understand, either from what you've written here or the rather
sparse comments in the patch, what this might be good for.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2014-12-19 13:40:09
Message-ID: 54942AB9.2020905@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 15/12/14 19:42, Robert Haas wrote:
> On Mon, Dec 15, 2014 at 12:57 AM, Petr Jelinek <petr(at)2ndquadrant(dot)com> wrote:
>> we've made few helper functions for making logical replication easier, I
>> bundled it into contrib module as this is mainly for discussion at this time
>> (I don't expect this to get committed any time soon, but it is good way to
>> iron out protocol, etc).
>>
>> I created sample logical decoding plugin that uses those functions and which
>> can be used for passing DML changes in platform/version independent
>> (hopefully) format.
>>
>> I will post sample apply BG worker also once I get some initial feedback
>> about this.
>>
>> It's hard to write tests for this as the binary changes contain transaction
>> ids and timestamps so the data changes constantly.
>>
>> This is of course based on the BDR work Andres, Craig and myself have been
>> doing.
>
> I can't understand, either from what you've written here or the rather
> sparse comments in the patch, what this might be good for.
>

What I tried to achieve here is to provide solution to many of the
common problems faced by logical replication solutions. I believe the
first step in designing the logical replication (now that we have the
logical decoding) is making the output plugin and the efficient protocol
so I started with that.

The code itself provides two main parts:
First is the lrep_utils common utility functions that solve things like
transporting DML statements, and more importantly the changed data in
efficient manner, trying to not do any conversion if not needed (when
architecture/version matches) but falling back to binary/textual IO
representation of individual types so that the cross platform/version
replication works too. I think those should eventually end up in core
(ie not in contrib) as they are helper functions likely to be shared by
multiple extensions, but for now I keep them with the rest of the
contrib module as I feel better experimenting inside that module.
There are also read functions that show how the other side could look
like, but they are currently unused as the example apply worker is not
part of the submission yet.

The second part is extensible output plugin which serves both as an
example of the intended use of those common utility functions and also
as actual working solution that can be used as base for several
replication solutions.
It provides hooks for the replication solutions built on top of it that
can be used for deciding if to replicate specific action on specific
object and also injecting additional information to both BEGIN and
COMMIT message - this can be useful for example when you are forwarding
changes from another node and you wish to pass the information about the
original node to the target one.

What I hope to get from this is agreement on the general approach and
protocol so that we can have common base which will both make it easier
to create external logical replication solutions and also eventually
lead to full logical replication inside core PostgreSQL.

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


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2014-12-22 13:26:52
Message-ID: CA+TgmoZrtQUMYAe8trzb=2BFSsaF_uFgZ5AJO=CUTR5zA9hQLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 19, 2014 at 8:40 AM, Petr Jelinek <petr(at)2ndquadrant(dot)com> wrote:
> What I hope to get from this is agreement on the general approach and
> protocol so that we can have common base which will both make it easier to
> create external logical replication solutions and also eventually lead to
> full logical replication inside core PostgreSQL.

The protocol is a really important topic which deserves its own
discussion. Andres has mentioned some of the ideas he has in mind -
which I think are similar to what you did here - but there hasn't
really been a thread devoted to discussing that topic specifically. I
think that would be a good idea: lay out what you have in mind, and
why, and solicit feedback.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Petr Jelinek <petr(at)2ndquadrant(dot)com>, ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2015-02-13 07:48:39
Message-ID: CAB7nPqTxTcppoyVpxTG+Cx40BMPROdSc2WFKhbXAJv7xYAWRRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Dec 22, 2014 at 10:26 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Fri, Dec 19, 2014 at 8:40 AM, Petr Jelinek <petr(at)2ndquadrant(dot)com>
> wrote:
> > What I hope to get from this is agreement on the general approach and
> > protocol so that we can have common base which will both make it easier
> to
> > create external logical replication solutions and also eventually lead to
> > full logical replication inside core PostgreSQL.
>
> The protocol is a really important topic which deserves its own
> discussion. Andres has mentioned some of the ideas he has in mind -
> which I think are similar to what you did here - but there hasn't
> really been a thread devoted to discussing that topic specifically. I
> think that would be a good idea: lay out what you have in mind, and
> why, and solicit feedback.
>

Looking at this patch, I don't see what we actually gain much here except a
decoder plugin that speaks a special protocol for a special background
worker that has not been presented yet. What actually is the value of that
defined as a contrib/ module in-core. Note that we have already
test_decoding to basically test the logical decoding facility, used at
least at the SQL level to get logical changes decoded.

Based on those reasons I am planning to mark this as rejected (it has no
documentation as well). So please speak up if you think the contrary, but
it seems to me that this could live happily out of core.
--
Michael


From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2015-02-13 13:04:59
Message-ID: 54DDF67B.1090809@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13/02/15 08:48, Michael Paquier wrote:
>
>
> On Mon, Dec 22, 2014 at 10:26 PM, Robert Haas <robertmhaas(at)gmail(dot)com
> <mailto:robertmhaas(at)gmail(dot)com>> wrote:
>
> On Fri, Dec 19, 2014 at 8:40 AM, Petr Jelinek <petr(at)2ndquadrant(dot)com
> <mailto:petr(at)2ndquadrant(dot)com>> wrote:
> > What I hope to get from this is agreement on the general approach and
> > protocol so that we can have common base which will both make it easier to
> > create external logical replication solutions and also eventually lead to
> > full logical replication inside core PostgreSQL.
>
> The protocol is a really important topic which deserves its own
> discussion. Andres has mentioned some of the ideas he has in mind -
> which I think are similar to what you did here - but there hasn't
> really been a thread devoted to discussing that topic specifically. I
> think that would be a good idea: lay out what you have in mind, and
> why, and solicit feedback.
>
>
> Looking at this patch, I don't see what we actually gain much here
> except a decoder plugin that speaks a special protocol for a special
> background worker that has not been presented yet. What actually is the
> value of that defined as a contrib/ module in-core. Note that we have
> already test_decoding to basically test the logical decoding facility,
> used at least at the SQL level to get logical changes decoded.
>
> Based on those reasons I am planning to mark this as rejected (it has no
> documentation as well). So please speak up if you think the contrary,
> but it seems to me that this could live happily out of core.

I think you are missing point of this, it's not meant to be committed in
this form at all and even less as contrib module. It was meant as basis
for in-core logical replication discussion, but sadly I didn't really
have time to pursue it in this CF in the end.

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


From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2015-02-15 14:25:59
Message-ID: 54E0AC77.10505@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13/02/15 14:04, Petr Jelinek wrote:
> On 13/02/15 08:48, Michael Paquier wrote:
>>
>> Looking at this patch, I don't see what we actually gain much here
>> except a decoder plugin that speaks a special protocol for a special
>> background worker that has not been presented yet. What actually is the
>> value of that defined as a contrib/ module in-core. Note that we have
>> already test_decoding to basically test the logical decoding facility,
>> used at least at the SQL level to get logical changes decoded.
>>
>> Based on those reasons I am planning to mark this as rejected (it has no
>> documentation as well). So please speak up if you think the contrary,
>> but it seems to me that this could live happily out of core.
>
> I think you are missing point of this, it's not meant to be committed in
> this form at all and even less as contrib module. It was meant as basis
> for in-core logical replication discussion, but sadly I didn't really
> have time to pursue it in this CF in the end.
>

That being said and looking at the size of February CF, I think I am
fine with dropping this in 9.5 cycle, it does not seem likely that there
will be anything useful done with this fast enough to get to 9.5 so
there is no point in spending committer resources on it in final CF.

I will pick it up again after the CF is done.

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


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, ">> PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Replication Helpers WIP for discussion
Date: 2015-02-16 03:22:18
Message-ID: CAB7nPqRALUJ_Huwz8G9oSE=YnXFK1rRB2FmtC-7ocTwj0-69iw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 15, 2015 at 11:25 PM, Petr Jelinek <petr(at)2ndquadrant(dot)com> wrote:

> On 13/02/15 14:04, Petr Jelinek wrote:
>
>> On 13/02/15 08:48, Michael Paquier wrote:
>>
>>>
>>> Looking at this patch, I don't see what we actually gain much here
>>> except a decoder plugin that speaks a special protocol for a special
>>> background worker that has not been presented yet. What actually is the
>>> value of that defined as a contrib/ module in-core. Note that we have
>>> already test_decoding to basically test the logical decoding facility,
>>> used at least at the SQL level to get logical changes decoded.
>>>
>>> Based on those reasons I am planning to mark this as rejected (it has no
>>> documentation as well). So please speak up if you think the contrary,
>>> but it seems to me that this could live happily out of core.
>>>
>>
>> I think you are missing point of this, it's not meant to be committed in
>> this form at all and even less as contrib module. It was meant as basis
>> for in-core logical replication discussion, but sadly I didn't really
>> have time to pursue it in this CF in the end.
>>
>>
> That being said and looking at the size of February CF, I think I am fine
> with dropping this in 9.5 cycle, it does not seem likely that there will be
> anything useful done with this fast enough to get to 9.5 so there is no
> point in spending committer resources on it in final CF.
>
> I will pick it up again after the CF is done.

OK, thanks for the clarifications. Note that I am marking it as "rejected"
in CF 2014-12 not because it is something that is not wanted, but just not
to re-add it to CF 2015-02 which is what "returned with feedback" actually
does...
--
Michael