aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index a230d7eda69..be961017d66 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -55,6 +55,7 @@
#include "pg_getopt.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
+#include "replication/slot.h"
#include "replication/walsender.h"
#include "rewrite/rewriteHandler.h"
#include "storage/bufmgr.h"
@@ -3854,6 +3855,16 @@ PostgresMain(int argc, char *argv[],
WalSndErrorCleanup();
/*
+ * We can't release replication slots inside AbortTransaction() as we
+ * need to be able to start and abort transactions while having a slot
+ * acquired. But we never need to hold them across top level errors,
+ * so releasing here is fine. There's another cleanup in ProcKill()
+ * ensuring we'll correctly cleanup on FATAL errors as well.
+ */
+ if (MyReplicationSlot != NULL)
+ ReplicationSlotRelease();
+
+ /*
* Now return to normal top-level context and clear ErrorContext for
* next time.
*/