Content-Length: 305740 | pFad | http://github.com/postgrespro/postgres/commit/77d21970ae19418f321e6a76ddf1a57ae999c77a

24 Fix connection leak in DROP SUBSCRIPTION command, take 2. · postgrespro/postgres@77d2197 · GitHub
Skip to content

Commit 77d2197

Browse files
committed
Fix connection leak in DROP SUBSCRIPTION command, take 2.
Commit 898a792 fixed the connection leak issue, but it was an unreliable way of bugfix. This bugfix was assuming that walrcv_command() subroutine cannot throw an error, but it's untenable assumption. For example, if it will be changed so that an error is thrown, connection leak issue will happen again. This patch ensures that the connection is closed even when walrcv_command() subroutine throws an error. Patch by me, reviewed by Petr Jelinek and Michael Paquier Discussion: https://www.postgresql.org/message-id/2058.1487704345@sss.pgh.pa.us
1 parent 044d9ef commit 77d2197

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/backend/commands/subscriptioncmds.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -565,19 +565,25 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
565565
"drop the replication slot \"%s\"", slotname),
566566
errdetail("The error was: %s", err)));
567567

568-
if (!walrcv_command(wrconn, cmd.data, &err))
568+
PG_TRY();
569+
{
570+
if (!walrcv_command(wrconn, cmd.data, &err))
571+
ereport(ERROR,
572+
(errmsg("could not drop the replication slot \"%s\" on publisher",
573+
slotname),
574+
errdetail("The error was: %s", err)));
575+
else
576+
ereport(NOTICE,
577+
(errmsg("dropped replication slot \"%s\" on publisher",
578+
slotname)));
579+
}
580+
PG_CATCH();
569581
{
570582
/* Close the connection in case of failure */
571583
walrcv_disconnect(wrconn);
572-
ereport(ERROR,
573-
(errmsg("could not drop the replication slot \"%s\" on publisher",
574-
slotname),
575-
errdetail("The error was: %s", err)));
584+
PG_RE_THROW();
576585
}
577-
else
578-
ereport(NOTICE,
579-
(errmsg("dropped replication slot \"%s\" on publisher",
580-
slotname)));
586+
PG_END_TRY();
581587

582588
walrcv_disconnect(wrconn);
583589

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/77d21970ae19418f321e6a76ddf1a57ae999c77a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy