0001-fix-assert-failure-in-logical-replication-apply-work.patch

application/octet-stream

Filename: 0001-fix-assert-failure-in-logical-replication-apply-work.patch
Type: application/octet-stream
Part: 0
Message: RE: Perform streaming logical transactions by background workers and parallel apply

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Fix assert failure in logical replication apply worker.
File+
src/backend/replication/logical/launcher.c 5 1
From a5a11494fdccbfec16ccc56d23dabfab7927a46d Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
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