Re: Logical replication and restore from pg_basebackup

From: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>
To: Dmitry Vasiliev <dmitry(dot)vasiliev(at)coins(dot)ph>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Logical replication and restore from pg_basebackup
Date: 2019-02-12 12:22:04
Message-ID: 67d1c1d6-420f-5c4d-dfc3-50c402e487d7@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dmitry,

On 11.02.2019 17:39, Dmitry Vasiliev wrote:
> What is the scope of logical replication if I cannot make recovery
> from pg_basebackup?

No, you can, but there are some things to keep in mind:

1) I could be wrong, but usage of pgbench in such a test seems to be a
bad idea, since it drops and creates tables from the scratch, when -i is
passed. However, if I recall it correctly, pub/sub slots use OIDs of
relations, so I expect that you should get only initial sync data on
replica and last pgbench results on master.

2) Next, 'srsubstate' check works only for initial sync. After that you
should poll master's replication slot lsn for 'pg_current_wal_lsn() <=
replay_lsn'.

Please, find attached a slightly modified version of your test (and gist
[1]), which works just fine. You should replace %username% with your
current username, since I did not run it as postgres user.

[1] https://gist.github.com/ololobus/a8a11f11eb67dfa1b6a95bff5e8f0096

Regards

--
Alexey Kondratov

Postgres Professional https://www.postgrespro.com
Russian Postgres Company

Attachment Content-Type Size
logical-replication-test.sh application/x-shellscript 2.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleksii Kliukin 2019-02-12 12:52:09 Re: Connection slots reserved for replication
Previous Message Antonin Houska 2019-02-12 11:43:34 Re: Problems with plan estimates in postgres_fdw