From be56cec12647052135a35a78c0d5a87dd5eebf68 Mon Sep 17 00:00:00 2001 From: Hayato Kuroda Date: Fri, 9 Jan 2026 19:31:57 +0900 Subject: [PATCH v3 2/2] Disallow setting the replication origin if it is being used PID is not stored --- src/backend/replication/logical/origin.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index dff2c073def..f373e3df2f9 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -1192,6 +1192,19 @@ replorigin_session_setup(RepOriginId node, int acquired_by) node, acquired_by))); } + /* + * PID was not noted in the origin. This can happen the process + * originally acquired the origin exits without releasing. To make the + * staus clean again, other processes cannot acquire the origin till + * all using ones release. + */ + else if (curstate->acquired_by == 0 && curstate->refcount > 0) + { + elog(ERROR, + "replication origin with ID %d is already active for another process", + node); + } + /* ok, found slot */ session_replication_state = curstate; break; -- 2.47.3