Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vfUak-002G4q-0s for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 02:57:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfUaj-002W5F-1U for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 02:57:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vfUaj-002W57-0P for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 02:57:09 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfUah-0008kI-1N for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 02:57:09 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-59b834e3d64so4046054e87.2 for ; Mon, 12 Jan 2026 18:57:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768273026; x=1768877826; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qvmDr0gaoP7NxvBLOKnWZVrpFfWLhZsEqvyRh7VpCIM=; b=aoB0OzZf/l4irTX+OBEsEPKsklu8xwQUD/TALV4sqL9zoO00hncYuj+7ewLmTcRvLI KfpoyA+g3qExVC00tOyDDzB2GkJQq541pzefCRLmgmTaI8CJxzsUeLQhRU6sOi5HeLmZ ybGLrMmPO4HgX1I07qasWdLHabhBRYE0XFBMGJEQ32UuMp2sAhRbosw0gEdqPPnXrWDj Td6xQ7WXKrQVxyQ3/P0PUp496nPQs+1+IWfr3fOIKEV4e5cMdqVcAav4IF+wYSQTOJJV uoz1ijIAVN/KyJP/GS8k6t0RzTQIoFkQ5xo9AAr/i+QAekLTcZr9do7CWvo2yqYuOKNr 1hhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768273026; x=1768877826; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qvmDr0gaoP7NxvBLOKnWZVrpFfWLhZsEqvyRh7VpCIM=; b=iglCmdiLi/wmtJPZhyVuB2DJVttACnpdAr+IHr0u1i54EcDmG/Vu6uRA7o2HQHv6MF QEIUcVwhVdpXPEq0ISqM8e8PhJvG4W4kNymyKb7uSdZ00NJFkck4enOIS29OBvyJI9R5 ZIS/f/Ad7vXy618KMEm2x9hhx7Er/pch9FxuZo8pC1BVKoHvtN0fZnS7CGROcyjKxRSh yJ7vJbxnBQwO+r5t1Zc64Thpnrh2Du1q8QqquDJORpoB6JgTnrGhfXdFmWPDNZ6kFf1J FCMWU1ZdWLz39tXIO7BKSsijo/J0ymqZtk8zf9Kvq5Unh6uwesL9tSyfwZwdQi5nPZOi /3Pg== X-Forwarded-Encrypted: i=1; AJvYcCVS1wBCvkF/UihlOs3OxlhwsH4zqMzkgwk7Qj7ivJbIckO41iZfHS8zppnXQt7HufBMVbO9F8VqFq9c8MFE@lists.postgresql.org X-Gm-Message-State: AOJu0YzacH9uQ6loSUhcMMkRDpzNQ8AfajZ0lwVWbalUD6nMmB93MJaI 5lNj8sQxU7Bk1Hju1h2Y20oZ5bQOuyaUnY3UDsfSXvtXaLLjcfZTyT0hUJNzuPfcBzOc7nk2f79 drjD5VYYLtAEDgnJAtkNaAFXDaEav8+4= X-Gm-Gg: AY/fxX6ArONRql1kxJXfwQyoK7uilTCH9Wk3fjYL/8SgZne+26j48E7BWzgDUi8f2a/ trt06JLVadK7AiqDnYd8ieSfQqyRYa16B4CDk9Ci7Qbr1rZNT+PEh+YKkL60b5SNMvJKgcvByR9 NPVsulz7PJXKDPN0pgrgV9sCwl1t2wY87A6hxQpSI1Ccfd5OmInXDsloTrmzeG2pSQBDgZ1mXoT nEq1bAVVgw/13JTSuUPb4m+wcMAybZW9EjcA1uuM/vzkzGc6e4ZNKiViB6Smgss7ZoYCr3aPTi7 Mxlb5XusZsWmg3hnZgeV7WZcw5qhokPrlqPEOXH+ X-Google-Smtp-Source: AGHT+IFZfeYWaJvfsgCIMnR8fMmBZkPeUvlklteVs9UHDApAS1Sn1bBGaY0MwDqVQoQFdCZXaX/eDQokSkwQIeAErCw= X-Received: by 2002:a2e:b88b:0:b0:383:1a8b:a330 with SMTP id 38308e7fff4ca-3831a8ba429mr42674891fa.4.1768273026201; Mon, 12 Jan 2026 18:57:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 13 Jan 2026 08:26:54 +0530 X-Gm-Features: AZwV_Qg02imtVpvChnlfpWNkrugi2Wa-n__w4T6haWpOyleM3TsavTPp4fqJYYU Message-ID: Subject: Re: [Patch] add new parameter to pg_replication_origin_session_setup To: shveta malik Cc: "Hayato Kuroda (Fujitsu)" , "Zhijie Hou (Fujitsu)" , Doruk Yilmaz , "pgsql-hackers@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 12, 2026 at 11:31=E2=80=AFAM shveta malik wrote: > > Please find a few comments: > > 1) > + /* > + * The replication origin cannot be reset if the replication origin is > + * firstly acquired by this backend and other processes are actively usi= ng > + * now. This can cause acquired_by to be zero and active replication ori= gin > + * might be dropped. > + */ > + if (session_replication_state->acquired_by =3D=3D MyProcPid && > + session_replication_state->refcount > 1) > + ereport(ERROR, > + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > + errmsg_plural("another process is acquiring the replication origin", > + "other processes are acquiring the replication origin", > + > > Since user is not aware of internal acquired_by logic, the error might > not make much sense to him as to why one session is able to reset > while another is not. Shall we make it: > > ERROR: cannot reset replication origin "origin_name" while it is > still shared by other processes > DETAIL: the current session is the first process for this replication > origin, and other processes are sharing it. > HINT: ensure this replication origin is reset in all other processes fir= st. > How about a slightly tweaked version of these messages: ERROR: cannot reset replication origin "origin_name" because it is still in use by other processes DETAIL: This session is the first process for this replication origin, and other processes are currently sharing it. HINT: Reset the replication origin in all other processes before retrying. > 2) > When the first session leaves, while the second session is still using > origin, the third session is able to drop the origin which is not > right. > I think replorigin_state_clear() needs a change. > 'if (state->acquired_by !=3D 0)' check should be replaced by 'if > (state->refcount > 0)' > > Patch 001 had correct changes in replorigin_state_clear(), IMO we > still need those > > 3) > When first session leaves, while second session is still using origin, > now correctly third session is not able to join it. It gives error: > postgres=3D# SELECT pg_replication_origin_session_setup('origin'); > ERROR: replication origin with ID 1 is already active for another process > > Error is not very informative provided the fact that now sharing is > allowed. Shall it be: > Yeah, sharing is allowed but only when used in parallel context by passing PID. I think a slightly modified version of the above message such as: "replication origin with ID 1 is already active in another process" should be sufficient. --=20 With Regards, Amit Kapila.