From 71da2685c8baf48d66cec7b737aa927e092d5f2c Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Thu, 15 Oct 2026 13:50:41 +0900 Subject: [PATCH v1] Skip the end-of-recovery logical WAL barrier at wal_level=logical XLogLogicalInfoActive() is always true at wal_level=logical, regardless of the process-local XLogLogicalInfo cache. Since changing wal_level requires a server restart, an existing process cannot later switch to wal_level=replica and start relying on a stale cached value. Skip emitting and waiting for the cache update barrier in this case, avoiding unnecessary coordination with all running processes before promotion can finish. Keep the shared logical decoding state update and any required WAL record unchanged. --- src/backend/replication/logical/logicalctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/logical/logicalctl.c b/src/backend/replication/logical/logicalctl.c index 8554df75a18..c8303a30bbf 100644 --- a/src/backend/replication/logical/logicalctl.c +++ b/src/backend/replication/logical/logicalctl.c @@ -665,8 +665,8 @@ DisableLogicalDecoding(void) /* * Updates the logical decoding status at end of recovery, and ensures that - * all running processes have the updated XLogLogicalInfo status. This - * function must be called before accepting writes. + * all running processes have the updated XLogLogicalInfo status when needed. + * This function must be called before accepting writes. */ void UpdateLogicalDecodingStatusEndOfRecovery(void) @@ -752,8 +752,11 @@ UpdateLogicalDecodingStatusEndOfRecovery(void) * XLogLogicalInfo even if we've not updated the status above as the * status have been turned on and off during recovery, having running * processes have different status on their local caches. + * + * With wal_level='logical', XLogLogicalInfoActive() is always true + * regardless of the cached XLogLogicalInfo value, so no barrier is needed. */ - if (IsUnderPostmaster) + if (IsUnderPostmaster && wal_level != WAL_LEVEL_LOGICAL) WaitForProcSignalBarrier( EmitProcSignalBarrier(PROCSIGNAL_BARRIER_UPDATE_XLOG_LOGICAL_INFO)); -- 2.56.0