From a5a11494fdccbfec16ccc56d23dabfab7927a46d Mon Sep 17 00:00:00 2001 From: Hou Zhijie Date: Wed, 26 Apr 2023 18:12:19 +0800 Subject: [PATCH] Fix assert failure in logical replication apply worker. The apply worker attempted to release the lock prior to completion of the process initialization, resulting in an assert failure. To resolve the issue, the lock is now released only if the apply worker has entered normal processing mode. --- src/backend/replication/logical/launcher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 970d170e73..447a4ceea7 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -797,8 +797,12 @@ logicalrep_worker_onexit(int code, Datum arg) * Session level locks may be acquired outside of a transaction in * parallel apply mode and will not be released when the worker * terminates, so manually release all locks before the worker exits. + * + * However, it's not necessary to release locks if the worker hasn't + * entered normal mode yet. */ - LockReleaseAll(DEFAULT_LOCKMETHOD, true); + if (IsNormalProcessingMode()) + LockReleaseAll(DEFAULT_LOCKMETHOD, true); ApplyLauncherWakeup(); } -- 2.30.0.windows.2