Re: [PATCH] Logical decoding support for sequence advances

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>, konstantin knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
Subject: Re: [PATCH] Logical decoding support for sequence advances
Date: 2015-12-15 12:46:29
Message-ID: 56700BA5.9080300@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-12-15 13:17, Andres Freund wrote:
> On 2015-12-14 16:19:33 +0800, Craig Ringer wrote:
>
>> Needed to make logical replication based failover possible.
>
> While it'll make it easier, I think it's certainly quite possible to do
> so without this feature if you accept some sane restrictions. If you
> e.g. define to only handle serial columns (i.e. sequences that
> used/owned by exactly one table & column), you can do a 'good enough'
> emulation the output plugin.
>
> Take something like BDR's bdr_relcache.c (something which you're going
> to end up needing for any nontrivial replication solution). Everytime
> you build a cache entry you look up whether there's an owned by
> sequence. When decoding an insert or update to that relation, also emit
> an 'increase this sequence to at least XXX' message.
>
> While it's not perfect, this has the big advantage of being doable with 9.4.
>

I don't think that approach alone is good enough. It might be ok for
selective replication where the replication is driven by tables anyway,
but in general and especially for failover it's not good enough to tell
user that we handle some sequences and they have to fix the rest
manually. That's not much different than fixing them all in practice as
you script it anyway.

However, if it was combined with something like what londiste does,
which is to check sequences periodically and send last_value + some
reasonable buffer, it could work well in most cases. In this scenario
your method would be used for checking that sequence is close to going
over buffer and firing the periodic send sooner than it would be if it
was purely time based.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-12-15 12:51:43 Re: [PATCH] Logical decoding support for sequence advances
Previous Message Andres Freund 2015-12-15 12:25:13 Re: Patch: fix lock contention for HASHHDR.mutex