diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-04-03 11:10:28 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-04-03 11:10:28 -0400 |
commit | 1116108c926820030bd18b5dbff9163c14e3ad6d (patch) | |
tree | 80f3e0eff99df37a2ebd8e65959c27032bf42704 /src | |
parent | 70da87d334ebe14fbbefe98827df5a8e1400444e (diff) | |
download | postgresql-1116108c926820030bd18b5dbff9163c14e3ad6d.tar.gz postgresql-1116108c926820030bd18b5dbff9163c14e3ad6d.zip |
Handle change of slot name in logical replication apply
Since change of slot name is a supported operation, handle it more
gracefully, instead of in the this-should-not-happen way.
Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/logical/worker.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index bbf3506be04..d6986f59c1c 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1351,6 +1351,21 @@ reread_subscription(void) } /* + * We need to make new connection to new slot if slot name has changed + * so exit here as well if that's the case. + */ + if (strcmp(newsub->slotname, MySubscription->slotname) != 0) + { + ereport(LOG, + (errmsg("logical replication worker for subscription \"%s\" will " + "restart because the replication slot name was changed", + MySubscription->name))); + + walrcv_disconnect(wrconn); + proc_exit(0); + } + + /* * Exit if publication list was changed. The launcher will start * new worker. */ @@ -1382,8 +1397,7 @@ reread_subscription(void) } /* Check for other changes that should never happen too. */ - if (newsub->dbid != MySubscription->dbid || - strcmp(newsub->slotname, MySubscription->slotname) != 0) + if (newsub->dbid != MySubscription->dbid) { elog(ERROR, "subscription %u changed unexpectedly", MyLogicalRepWorker->subid); |