From 915f245d4bccc8ad6536a3d64f4eb6b9afd55804 Mon Sep 17 00:00:00 2001 From: Anastasia Lubennikova Date: Tue, 4 Mar 2025 02:17:16 +0000 Subject: [PATCH] Do not drop tablesync replication slots on the publisher when we're in the process of dropping subscriptions inherited by a neon branch. Because these slots are still needed by the parent branch subscriptions. For regular slots we handle this by setting the slot_name to NONE before calling DROP SUBSCRIPTION, but tablesync slots are not exposed to SQL. rely on GUC disable_logical_replication_subscribers=true to know that we're in the Neon-specific process of dropping subscriptions. --- src/backend/commands/subscriptioncmds.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 8ecb6e0bb87..c3d541b59d8 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -1809,7 +1809,17 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel) ReplicationSlotNameForTablesync(subid, relid, syncslotname, sizeof(syncslotname)); - ReplicationSlotDropAtPubNode(wrconn, syncslotname, true); + + if (disable_logical_replication_subscribers) + { + ereport(LOG, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("skip dropping tablesync slot \"%s\" when disable_logical_replication_subscribers=true", syncslotname))); + } + else + { + ReplicationSlotDropAtPubNode(wrconn, syncslotname, true); + } } }