Right way to restore logical replication

From: Игорь Выскорко <vyskorko(dot)igor(at)yandex(dot)ru>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Right way to restore logical replication
Date: 2021-02-08 15:42:21
Message-ID: 558981612798690@mail.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<div><div><div>Hi, community!</div><div>Unfortunately can't find answer in docs and google. Hope only for you)</div><div>Have running 2 postgres locally: </div><div>:5433 - postgres 11 as master</div><div>:5434 - postgres 12 as slave</div><div> </div><div>Creating basic setup for testing:</div><div>[local]:5433 postgres(at)postgres=# create table tbl(id serial, d text, primary key(id));</div><div>CREATE TABLE</div><div>Time: 7,147 ms</div><div> </div><div>[local]:5434 postgres(at)postgres=# create table tbl(id serial, d text, primary key(id));</div><div>CREATE TABLE</div><div>Time: 11,557 ms</div><div> </div><div>[local]:5433 postgres(at)postgres=# create publication pub for table tbl;</div><div>CREATE PUBLICATION</div><div>Time: 6,646 ms</div><div> </div><div>[local]:5434 postgres(at)postgres=# create subscription sub connection 'host=localhost port=5433 dbname=postgres user=postgres' publication pub;</div><div>NOTICE:  created replication slot "sub" on publisher</div><div>CREATE SUBSCRIPTION</div><div>Time: 18,584 ms</div><div> </div><div>[local]:5433 postgres(at)postgres=# insert into tbl(d) values ('test');</div><div>INSERT 0 1</div><div>Time: 3,401 ms</div><div> </div><div>[local]:5434 postgres(at)postgres=# select * from tbl;</div><div> id |  d   </div><div>----+------</div><div>  1 | test</div><div>(1 row)</div><div> </div><div>works like a charm. Ok. Lets drop "accidentally" publication and insert new data:</div><div> </div><div>[local]:5433 postgres(at)postgres=# drop publication pub ;</div><div>DROP PUBLICATION</div><div>Time: 3,793 ms</div><div> </div><div>[local]:5433 postgres(at)postgres=# insert into tbl(d) values ('test2');</div><div>INSERT 0 1</div><div>Time: 9,002 ms</div><div> </div><div>Log for master:</div><div> </div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres LOG:  starting logical decoding for slot "sub"</div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres DETAIL:  Streaming transactions committing after 8/FD435A80, reading WAL from 8/FD436948.</div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres LOG:  logical decoding found consistent point at 8/FD436948</div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres DETAIL:  There are no running transactions.</div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres ERROR:  publication "pub" does not exist</div><div>2021-02-08 22:13:14.970 +07 [14075] postgres(at)postgres CONTEXT:  slot "sub", output plugin "pgoutput", in the change callback, associated LSN 8/FD4369E8</div><div> </div><div>slave:</div><div>2021-02-08 22:13:45.071 +07 [14110] LOG:  logical replication apply worker for subscription "sub" has started</div><div>2021-02-08 22:13:45.078 +07 [14110] ERROR:  could not receive data from WAL stream: ERROR:  publication "pub" does not exist</div><div>    CONTEXT:  slot "sub", output plugin "pgoutput", in the change callback, associated LSN 8/FD4369E8</div><div>2021-02-08 22:13:45.079 +07 [18374] LOG:  background worker "logical replication worker" (PID 14110) exited with exit code 1</div><div> </div><div>Looks reasonable - publication pub does not exist. Ok, trying to recreate publication:</div><div>[local]:5433 postgres(at)postgres=# create publication pub for table tbl;</div><div>CREATE PUBLICATION</div><div>Time: 6,646 ms</div><div> </div><div>result: nothing changed, same errors appears again and again. I couldn't find how to restore replication without drop&amp;create subscription again. </div><div> </div><div>Questions here:</div><div>1. what is going under the hood here - why walsender thinks that "publication "pub" does not exist" when it actually exists?</div><div>2. what is the right way to restore replication in my example?</div><div> </div><div>Thanks!</div><div> </div></div></div>

Attachment Content-Type Size
unknown_filename text/html 3.7 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joao Miguel Ferreira 2021-02-08 16:39:06 identifier will be truncated
Previous Message Tom Lane 2021-02-07 22:25:14 Re: SV: Problem with pg_notify / listen