summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut2017-01-25 15:47:53 +0000
committerPeter Eisentraut2017-01-25 15:47:53 +0000
commit65df150a18d4a24e6870eb4a3db28ac8a6c23603 (patch)
tree9693ec3753e90d6f4a81787d3b3f94b4ede9bb2b /src
parentaebeb4790c750dc808c1c5afb3cb435116244e36 (diff)
Close replication connection when slot creation errors
From: Petr Jelinek <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/subscriptioncmds.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 2b6d3225594..e0add949534 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -301,10 +301,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt)
ereport(ERROR,
(errmsg("could not connect to the publisher: %s", err)));
- walrcv_create_slot(wrconn, slotname, false, &lsn);
- ereport(NOTICE,
- (errmsg("created replication slot \"%s\" on publisher",
- slotname)));
+ PG_TRY();
+ {
+ walrcv_create_slot(wrconn, slotname, false, &lsn);
+ ereport(NOTICE,
+ (errmsg("created replication slot \"%s\" on publisher",
+ slotname)));
+ }
+ PG_CATCH();
+ {
+ /* Close the connection in case of failure. */
+ walrcv_disconnect(wrconn);
+ PG_RE_THROW();
+ }
+ PG_END_TRY();
/* And we are done with the remote side. */
walrcv_disconnect(wrconn);