Re: Design for In-Core Logical Replication

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Hannu Krosing <hkrosing(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Design for In-Core Logical Replication
Date: 2016-07-26 11:37:16
Message-ID: a43140b1-198f-026a-2314-e34c9bc324c1@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26/07/16 00:05, Hannu Krosing wrote:
>> <programlisting>
>> CREATE PUBLICATION mypub;
>> ALTER PUBLICATION mypub ADD TABLE users, departments;
>> </programlisting>
> Would a subscription just be a logical grouping or would it be something
> stronger
> like meaning atomic subscriptions and/or a dedicated replication slot ?
>

Not sure what you mean by atomic subscription but subscription creation
adds replication slot to the provider node. Other than that subscription
lives on the downstream node only.

> Can you subscribe to multiple publications through single SUBSCRIPTION ?
>

Yes.

> What is supposed to happen if table A is in two subscriptions S1 and S2,
> and you
> subscribe to both? Will you get table a only once (both initial copy and
> events)?

Yes only once, the replication works with tables, publication is really
just grouping/filtering, what you get is union of tables in the
publications.

>
> Would a subscription of "mypub" pop up on subscriber side atomically, or
> will subscribed
> tables appear one-by one when they are ready (initial copy + catchup
> event replay completed) ?
>

Yes that's my plan as that makes it easier to parallelize and recover
from crashes (also makes this faster as tables that are already done
don't need to be copied again) during the initialization. Also makes it
easier to reuse the table initialization code for adding new tables at
later time.

>> <programlisting>
>> CREATE SUBSCRIPTION mysub WITH CONNECTION <quote>dbname=foo host=bar
>> user=repuser</quote> PUBLICATION mypub;
>> </programlisting>
> For the pgq-like version which consider a PUBLICATION just as list of
> tables to subscribe, I would add
>
> CREATE SUBSCRIPTION mysub WITH CONNECTION 'dbname=foo host=bar
> user=repuser' PUBLICATION mypub, mypub1;
>

Yes that works as well.

> ALTER SUBSCRIPTION mysub DROP PUBLICATION mypub1;
>
> ALTER SUBSCRIPTION mysub ADD PUBLICATION mypub2;
>

This does not yet, but I agree we should have it.

--
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 Fujii Masao 2016-07-26 12:18:30 Re: Confusing TAP tests readme file
Previous Message Michael Paquier 2016-07-26 09:08:56 Re: pg_dumping extensions having sequences with 9.6beta3