diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-04-21 08:35:24 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-04-21 08:37:03 -0400 |
commit | dcb39c37c1d3b90115e1501af8efb7af59c341c3 (patch) | |
tree | a4bbc616009267c0044227e4bab80d32f350fc1a | |
parent | 77c316be7e6950990f21ba58f78ce67db1950fa9 (diff) | |
download | postgresql-dcb39c37c1d3b90115e1501af8efb7af59c341c3.tar.gz postgresql-dcb39c37c1d3b90115e1501af8efb7af59c341c3.zip |
Synchronize table list before creating slot in CREATE SUBSCRIPTION
This way a failure to synchronize the table list will not leave an
unused slot on the publisher.
Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
-rw-r--r-- | src/backend/commands/subscriptioncmds.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 35dccbc0ad6..c29a57ed52d 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -395,20 +395,6 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) PG_TRY(); { /* - * If requested, create permanent slot for the subscription. - * We won't use the initial snapshot for anything, so no need - * to export it. - */ - if (create_slot) - { - walrcv_create_slot(wrconn, slotname, false, - CRS_NOEXPORT_SNAPSHOT, &lsn); - ereport(NOTICE, - (errmsg("created replication slot \"%s\" on publisher", - slotname))); - } - - /* * Set sync state based on if we were asked to do data copy or * not. */ @@ -432,6 +418,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) ereport(NOTICE, (errmsg("synchronized table states"))); + + /* + * If requested, create permanent slot for the subscription. + * We won't use the initial snapshot for anything, so no need + * to export it. + */ + if (create_slot) + { + walrcv_create_slot(wrconn, slotname, false, + CRS_NOEXPORT_SNAPSHOT, &lsn); + ereport(NOTICE, + (errmsg("created replication slot \"%s\" on publisher", + slotname))); + } } PG_CATCH(); { |