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 1wZofJ-001Ih0-3A for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2026 11:42:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZofH-005lvv-1c for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2026 11:42:39 +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 1wZofH-005lvn-0a for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2026 11:42:39 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZofE-00000000u0u-44wH for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2026 11:42:38 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5ad49da7123so415404e87.0 for ; Wed, 17 Jun 2026 04:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781696555; cv=none; d=google.com; s=arc-20240605; b=P0YfV94txmCrXCbBlXbwKckgKjEdEVd+tl9mDzwZKwsr7qeO/LJL1wrAbHu4apur6F f/NzUP3e3BvsqKSDjemWfD1CRXdgvCreEz8l7yz7qdERci7jk3OuD4TyjyGPOUgIv+XH /Ws7n0EVTbLY67mhAmiJW2IP+znxZ+aDrWiJRxKIGhjV2ZtliXroidG7x/ws7puYFEv4 iciFhryih4PiW4obOoyzypz0HqpwnmoCMFhV4Pi8VEw8YBRupW0ZHpSMWoDU6ee8om3/ ksDONMTvUgaLphqkilLP2WvfV8fQIId97dojrxamWhRIe35cfXct51D9s6w9tZ6hp9h5 ypiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Xkr1ybWkt9b2oKiOcrc/X9rKz5O+Q8OcglB5N0jDhsE=; fh=FnSA66ou4IklTQOMUBTBo9FKdDn/nA4gV11IwSGxBao=; b=VpIcg4YekpiOIgORO7sfXAY5lSbgd0MO92pWt4MNc5JEj3O2jw2aoG0iJAQgDWlj6F 3LoFRDH33Go9U+eJ3lmgdUj8z2vOTvSc6areLPxNx3ONQ8SJ0F4yuvCtVCROXTb4NG0n kaKpBFYKInaizpb5NTSE07+83hGCcMvrTGMaB57ssncHV4jPZybLTEW4FWNvGI8EEhNh xTPJZxMPnVtuvNjdV5+uZvBSrZwWmJrN/6+yudJRYMkfhX45yENEJykIHSQaTgGSHtw6 54TZ9r+u19vEb1PF3jgHeQ1+Dm4xEn3/L+7RttB+AG3XKWCCDw5HFRsFcwqJewdxrPyU F3Wg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781696555; x=1782301355; 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=Xkr1ybWkt9b2oKiOcrc/X9rKz5O+Q8OcglB5N0jDhsE=; b=HGaI/CZzVCUVbxf/Rf9elx+DA1ye/oMa8HT8ThmS5zgBGlaW33N29OHXuYjIXD5aJy wfxQwPSDnLmEY3r8ilwGZfiPSGCZ97hfCC3NdF4zAGeew+/lgGGRnpMhjqn0rMxFVSl5 8YJK7OEjB5wS+uK3v+f/2xGk+gVXkddgsn7JCaGocJS1QPr4lCwTysQb4BLLJmm9+9PR 8qtWJBzzdU9K4DFxJet3X7R6ZdpYLtFQGN2PwsAobqNnqPu52hvHqPU0as9NPn6JazXL tIDv1zVVmqyPIKpkaH/7ECmywvrYGsqD144duenLmw1d3BqaqlHqpRK8w8gtmglw19ww nMQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781696555; x=1782301355; 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=Xkr1ybWkt9b2oKiOcrc/X9rKz5O+Q8OcglB5N0jDhsE=; b=CREhNmRMQmeeJxUjYpz3TJNtAGV2KOoa0ThBgiyiLchL5JqsalitVs7DnHZWJm5VnP 2lYTRickaDkyA+3dftzy4x54ZEhKiy++Xd+XcC3nZGT4gZirCN/41EafYjyfWesExV+2 2oxn8eRROD9vu5MqtHdFtHfP5MiMJW6Z7wZKBmlf2g6XJitNhRhYORZt25xZwxDDpFEc X3fKSIETAFguC4B9OHZ91GupBMbbKZ399gieQ/9PXVpVgCl3B6aKwCoxihuuisIQTbMW GC0LBTsQYegR4vCLSBMPri/VsFx8dQkK9vw3m+HhRPAkoa9ZdKEBMQuqIp9xonE1FQ2h I+4A== X-Forwarded-Encrypted: i=1; AFNElJ/hRifhXI3pVemm0yZFGTUVKzIIiopCWssfwSgaZHYtXXxxVn+8olDRhaSbqi4pZFVSuJv7URe1ZkmMHJo6@lists.postgresql.org X-Gm-Message-State: AOJu0YzhvHtVLuPOapD4FZeEKrvI4FTyRQ3SQnDG4dTkk0nY9b5OopBh zbmpuerJjjsVzyAqh0zm66IhgH4vQOIFVycYyu120YaXuVfF3rrcy618mXULdxjED7J0TtJ0PJQ ydDogVKVLGMQ9vylStxE2m0NXX62jeg== X-Gm-Gg: AfdE7cnwjAFq3ug9fsG9Oil0whL/B9wqmH7MGO/CQmYJwxGIf1sz4yVAcBQ64eBMc8V ic9CGhUSnKcn6ZRYdSvMszGXg1l3xLVLPjVBDhaWEP7RVQd21Loh+x1sk4B3kG6JfA7VNSRvjAM Wsm6MlQAPgM0fF/TUdCogvgbqcY8mipQxekcLWaK7ujxkIlYHgjjOLs9EaJCEU+fP5uAFBOxO7b X8IBOtrv7fQ66D9Y6OJG60jHyqMUCM4UOzAmVroNe9vVwzVMd1UCTgVhra7V5UDq8Vd0VCE8BGu 854hSnixhBGc17YPk1vRfuK2a78l X-Received: by 2002:ac2:4c3b:0:b0:5aa:6cfc:a222 with SMTP id 2adb3069b0e04-5ad481348demr548667e87.24.1781696555210; Wed, 17 Jun 2026 04:42:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Wed, 17 Jun 2026 17:12:22 +0530 X-Gm-Features: AVVi8Cf3ITT59eA1klftgMQHYRw4F-stE4MuKFqVEWxBqCpgycc9CWdVhxSbi94 Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian Cc: Shlok Kyal , shveta malik , Zsolt Parragi , vignesh C , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers , shveta malik 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 Wed, Jun 17, 2026 at 4:29=E2=80=AFPM Nisha Moond wrote: > > On Wed, Jun 17, 2026 at 2:49=E2=80=AFPM Ajin Cherian = wrote: > > > > I have addressed the comments in v8 (attached). I've also now taken > > out the check for PG17 on old cluster and now all clusters which have > > replication origins are migrated. > > Hi Ajin, Thanks for the patches. > I have started reviewing the patches. Please find a few initial > comments below (from v7 review, still applicable to v8): Please find a couple more comments for the v8-002 patch: 4) I was able to build successfully without all three new header inclusions below, so we may not need them. --- a/src/backend/utils/adt/pg_upgrade_support.c +++ b/src/backend/utils/adt/pg_upgrade_support.c @@ -11,6 +11,7 @@ +#include "access/genam.h" ... +#include "utils/fmgroids.h" ... +#include "utils/snapmgr.h" ~~~ 5) Race condition in origin.c: replorigin_create() - heap_freetuple(tuple); + table_close(rel, ExclusiveLock); + + replorigin_create_with_id(roident, roname, InvalidXLogRecPtr); + Due to the above refactoring, CREATE SUBSCRIPTION can now fail because of a race between two concurrent CREATE SUBSCRIPTION commands: postgres=3D# create subscription sub2 connection 'dbname=3Dpostgres host=3Dlocalhost port=3D7733' publication pub1; ERROR: replication origin with ID 2 already exists I think this happens because the table lock is released, allowing another session to create a pg_origin with the next available roident, which replorigin_create_with_id() later attempts to use. Would it make sense to call replorigin_create_with_id() before table_close() so the lock is still held? I tested this and it works, though I'm not fully sure whether self-locking could be a concern here, since replorigin_create_with_id() again acquires a RowExclusiveLock on the same table. ~~~ -- Thanks, Nisha