Commit dcb39c37 authored by Peter Eisentraut's avatar Peter Eisentraut

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>
parent 77c316be
...@@ -394,20 +394,6 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) ...@@ -394,20 +394,6 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
PG_TRY(); 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 * Set sync state based on if we were asked to do data copy or
* not. * not.
...@@ -432,6 +418,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) ...@@ -432,6 +418,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
ereport(NOTICE, ereport(NOTICE,
(errmsg("synchronized table states"))); (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(); PG_CATCH();
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment