From 22f9200f2985fd99cafcfe804b26b6e82b2449c5 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Wed, 11 Feb 2026 10:39:51 +0800 Subject: [PATCH v1] logicalctl: release LogicalDecodingControlLock before logging In DisableLogicalDecoding(), the LOG message reporting that logical decoding has been disabled was emitted while still holding LogicalDecodingControlLock. Although ereport(LOG, ...) is not expected to error out, it is generally better practice to avoid performing logging while holding LWLocks when not strictly necessary. Move the LWLockRelease() call so that the lock is released before emitting the LOG message. Author: Chao Li --- src/backend/replication/logical/logicalctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/replication/logical/logicalctl.c b/src/backend/replication/logical/logicalctl.c index 4e292951201..1b229ebee66 100644 --- a/src/backend/replication/logical/logicalctl.c +++ b/src/backend/replication/logical/logicalctl.c @@ -528,12 +528,12 @@ DisableLogicalDecoding(void) END_CRIT_SECTION(); + LWLockRelease(LogicalDecodingControlLock); + if (!in_recovery) ereport(LOG, errmsg("logical decoding is disabled because there are no valid logical replication slots")); - LWLockRelease(LogicalDecodingControlLock); - /* * Tell all running processes to reflect the xlog_logical_info update. * Unlike when enabling logical decoding, we don't need to wait for all -- 2.50.1 (Apple Git-155)