Skip to content

Commit dcb39c3

Browse files
committed
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>
1 parent 77c316b commit dcb39c3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/backend/commands/subscriptioncmds.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -394,20 +394,6 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
394394

395395
PG_TRY();
396396
{
397-
/*
398-
* If requested, create permanent slot for the subscription.
399-
* We won't use the initial snapshot for anything, so no need
400-
* to export it.
401-
*/
402-
if (create_slot)
403-
{
404-
walrcv_create_slot(wrconn, slotname, false,
405-
CRS_NOEXPORT_SNAPSHOT, &lsn);
406-
ereport(NOTICE,
407-
(errmsg("created replication slot \"%s\" on publisher",
408-
slotname)));
409-
}
410-
411397
/*
412398
* Set sync state based on if we were asked to do data copy or
413399
* not.
@@ -432,6 +418,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
432418

433419
ereport(NOTICE,
434420
(errmsg("synchronized table states")));
421+
422+
/*
423+
* If requested, create permanent slot for the subscription.
424+
* We won't use the initial snapshot for anything, so no need
425+
* to export it.
426+
*/
427+
if (create_slot)
428+
{
429+
walrcv_create_slot(wrconn, slotname, false,
430+
CRS_NOEXPORT_SNAPSHOT, &lsn);
431+
ereport(NOTICE,
432+
(errmsg("created replication slot \"%s\" on publisher",
433+
slotname)));
434+
}
435435
}
436436
PG_CATCH();
437437
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy