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 1wZPxy-0011Vk-2T for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 09:20:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZPxx-00GQhD-1f for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 09:20:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wZPxx-00GQh5-0J for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 09:20:17 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZPxv-00000000cTP-2mOH for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 09:20:16 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5aa66893e9fso5582105e87.1 for ; Tue, 16 Jun 2026 02:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781601614; cv=none; d=google.com; s=arc-20240605; b=CFssvDhmMITEAMX+YW5iIjvmEnNKGJhlKweLBsGthYHq2X2Sd6A95q/7ic2Rucjkmm 9AD5jp/an58Dv4FBcAJbdSsIuIeqV60iIsefQGrlHPOyJyq5tJbxdUQfxgmkF4k7UXd1 CViRT2zOQB82tQXNpVRxueSxYrN6lsPnX1aK4aH7Swrobgk4uaKzdw8a+r6kZq/di7FP vBFGRiR2pib96PaIowCAJ6lT8YKTBkGCc21X9SQRMOevengZEf271f1IUxyNDGpU0rLq 0wrUI7DpjB8Ltmt8vT/scY4DKLG82FD0QREAQwrSLBmkKLQQ+vWTCCSK/BAIM1MKmDWp ZAJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=q4nB59/c+hH9yHUeMRFSJNKQEUhGgNbXf1ssDg3Ub08=; fh=VznkforSlwEB7sDa2G9ONQDRJj0ZezdOCPSwLiYRTTw=; b=LN3dsNf7R1zAwcXHN0fUD9SwpynoGVWL1sukfK35LMMRNGCO5XqH7ovyMPZ/ftBDLS v7IHNwPL7iK9e3Q0JELyKEPu1SQ30Z2itTMyPBNXsEIKsm3Mb4TyXpfjcd/6p7gTe/KT nIwJsGKmlc5FY3xuuyfSw+9B0H+K9qLTKnWji+MzBq4UMJS+We79oU3YiSQULhmojMZf bVJOplv+F35n1gq4oYMM6LVizf+5oyRz7c38sncTHSCVeGZy55WsH504lm68xXLo/+xu oLGg5ibUMxuSnhRdLKnJDNYxvKyXZahvSHzBXWFS1dWnf3es8GRpOTvW5yUZaNixWuOv gyDg==; 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=1781601614; x=1782206414; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q4nB59/c+hH9yHUeMRFSJNKQEUhGgNbXf1ssDg3Ub08=; b=pk1O58GKuEumkuImPU/JKk5RtVfRAqL4X6bsjdY0CIvXqHNC01Cj1LP3U3MtErXMHD RtuR5YoDKviTOc/+L5to9UAipTZGz0DPkVETDk5/Q2dvkb3OTOWin4AjXeHnfKtF6w6M qB8OZpte4xWs5mXoleyskfeLl9ko8j4bJcNPO+ILfH61bhwnveGamx/ySxRcG7ktJeqr SugiyhJVDXMhzkvzCy+USfpATXb8RPY8HideNNVFZQaK0BiInFbLgRjoqjYOD0bd9Ak8 z25XVXhzZl6mAmFfii6izxtGp0YTdb8eXLrQJ3mWsFsoeEbtUTxZgslggAJoMBV5jKq9 gYpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781601614; x=1782206414; h=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=q4nB59/c+hH9yHUeMRFSJNKQEUhGgNbXf1ssDg3Ub08=; b=IKsxoEMwO3xFTmUWivKu37wvtBERk+nWGS/+2t5Te1pX4Vg0u35AmDpuqc0bh4gKei ZHVnbO5VbqWl9CN0sgD/S5RCF7UlmbfwsgB2WAhXy6noVU84LLHYovvBSLt0tfLm+SmN soLh3Q4HsY8WZxmb6+A+2FpnOGdjbcFZ++T6RF9snwI44XeAVGsImhj56tAx7BhVKX/q fTiHDoKTolmUc38aGI0fIVVwaC6pk7N+9gCdh+3riiLqY4h77MnL43A1vXCsSZmQsHE7 pUe/24b5A3RZ7TOb48AlGNMbOJcgnb1CL/oo8VChdbT3kxOY1ZqjqbExFsK6uDvP0wJi 7XHw== X-Forwarded-Encrypted: i=1; AFNElJ90+HDTodxZxWiwxhRLxQV4QoC8lRPRtvU1iKslyIClgAxuA2L+vP6oJhFi1SRB+0npfXO4dtuZFuAvVPjb@lists.postgresql.org X-Gm-Message-State: AOJu0Ywvnze7tcsTaH10uwRG8rOg6VFUP/rPvCZZwzY9FFXQykda+bW6 FkI3oPcnrGMP7r96ZZF6eLqt33gHiSlX3SFt4iBKCsFiLnaQ6MeGLWTnc2KncAm+SrpnfXpOQVh PfRaVDIsmd4NFfTz0VPr9wfuaGKp/MsY= X-Gm-Gg: Acq92OG9Hcw11c5LXhm1osDHJjv9UHeSeSeD9AgNJjMM+wvFkktKxEuVywjp1r6esn6 R+JKmwRcnUug6prwAQvIFgRvEYsJ7am7SPcpEfscneWku/OyfPekDtAg9vIVgpkkIVPFtdJ/bsf PKFpQh7hk7o/VVQkRTNiH47vzejAyGbWFux/el5tw6MXxVrsOGNP43Ym39T75FZRnZDOFmouyr9 vueNyyHq15ww4quvB4Jvzxc5ZeQH0L6OZw6oQGYjSd1FbHTJ9xcg0A6hWC2SUDYnyVmhW+1g42+ 4JJgre7xwBRUUaS2p5NJ+AMBjSFP3d6uO7uYwDNjd4RL1+wt/QFHNvQMLbA6ai9QfrPbVx5IXfX dOy6M1A== X-Received: by 2002:a05:6512:800e:10b0:5ad:abf:1e1d with SMTP id 2adb3069b0e04-5ad43313919mr660039e87.8.1781601613251; Tue, 16 Jun 2026 02:20:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ajin Cherian Date: Tue, 16 Jun 2026 19:20:01 +1000 X-Gm-Features: AVVi8CezbB33JNyHBPTOYw55s6Z6WQwWZLhD9Tr5ioNtltZVB9_ZPbdN_N1f830 Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Amit Kapila Cc: shveta malik , Shlok Kyal , Dilip Kumar , Zsolt Parragi , vignesh C , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="0000000000004a0a7e06545b73f0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004a0a7e06545b73f0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 15, 2026 at 9:31=E2=80=AFPM Amit Kapila wrote: > > > I'd prefer option-3 (preserve origin IDs uniformly, including upgrades > from PG16), for two reasons. (a) First, the new-cluster check ("reject > if the new cluster already has replication origins") is a restriction > on the target, and adding restrictions on a newer target version > regardless of source version is well within how pg_upgrade already > behaves. In practice the new cluster is a fresh initdb with no > origins, so the check effectively never fires; the only scenario it > rejects is one where the user manually created subscriptions/origins > on the new cluster before upgrading, which we discourage for other > object types anyway. So I don't think preserving existing behavior > here is worth much. (b) Second, option-2 reintroduces source-version > branching at dump time (the skip_subs_origin_creation flag gated on > source >=3D 17). Since pg_commit_ts is only copied from PG19+, the exact > roident value only matters from PG19; for PG16-18 the value is > don't-care, so preserving it everywhere is harmless where it isn't > needed and required where it is. That lets us keep a single > always-preserve path instead of branching per source version. > > Ok. > Separately, I don't think we actually need to preserve the > subscription OID to meet the goal here. pg_commit_ts stores the > numeric roident, not the origin name or the sub OID, and conflict > detection compares roidents. So the invariant we must keep is "each > subscription owns the same roident after upgrade", which doesn't > depend on the name being stable. > > > Replication origins are global objects and are therefore dumped by pg_dumpall, while subscriptions are database-specific and are dumped by pg_dump. In pg_upgrade, pg_dumpall runs before pg_dump. The complication if subscription OID is not preserved is that subscription-associated origins derive their name from the subscription's OID. If the subscription OID is not preserved across upgrades, the origin name on the new cluster will differ from the old one, making it impossible to restore the origin independently. For these origins, creation must happen after CreateSubscription has established the new OID and not upfront in pg_dumpall. Non-subscription origins have no such dependency and continue to be created separately as before. The subscription code also cannot be left untouched: even once the subscription is created, rather than origin being created inside CreateSubscription, its associated origin must still be explicitly created via binary_upgrade_create_replication_origin to ensure the roident matches the original node, which means CreateSubscription needs to be modified anyways. So, there is an advantage of reducing code if subscription OID is preserved and all origins keep the same name as the old node. regards, Ajin Cherian Fujitsu Australia --0000000000004a0a7e06545b73f0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Jun 15,= 2026 at 9:31=E2=80=AFPM Amit Kapila <amit.kapila16@gmail.com> wrote:


I'd prefer option-3 (preserve origin IDs uniformly, including upgrades<= br> from PG16), for two reasons. (a) First, the new-cluster check ("reject=
if the new cluster already has replication origins") is a restriction<= br> on the target, and adding restrictions on a newer target version
regardless of source version is well within how pg_upgrade already
behaves. In practice the new cluster is a fresh initdb with no
origins, so the check effectively never fires; the only scenario it
rejects is one where the user manually created subscriptions/origins
on the new cluster before upgrading, which we discourage for other
object types anyway. So I don't think preserving existing behavior
here is worth much. (b) Second, option-2 reintroduces source-version
branching at dump time (the skip_subs_origin_creation flag gated on
source >=3D 17). Since pg_commit_ts is only copied from PG19+, the exact=
roident value only matters from PG19; for PG16-18 the value is
don't-care, so preserving it everywhere is harmless where it isn't<= br> needed and required where it is. That lets us keep a single
always-preserve path instead of branching per source version.


Ok.
=C2=A0
Separately, I don't think we actually need to preserve the
subscription OID to meet the goal here. pg_commit_ts stores the
numeric roident, not the origin name or the sub OID, and conflict
detection compares roidents. So the invariant we must keep is "each subscription owns the same roident after upgrade", which doesn't depend on the name being stable.



Replication origins are global obj= ects and are therefore dumped by pg_dumpall, while subscriptions are databa= se-specific and are dumped by pg_dump. In pg_upgrade, pg_dumpall runs befor= e pg_dump.

The complication if subscription OID is not preserved is = that subscription-associated origins derive their name from the subscriptio= n's OID. If the subscription OID is not preserved across upgrades, the = origin name on the new cluster will differ from the old one, making it impo= ssible to restore the origin independently. For these origins, creation mus= t happen after CreateSubscription has established the new OID and not upfro= nt in pg_dumpall.

Non-subscription origins have no such dependency a= nd continue to be created separately as before. The subscription code also = cannot be left untouched: even once the subscription is created, rather tha= n origin being created inside CreateSubscription, its associated origin mus= t still be explicitly created via binary_upgrade_create_replication_origin = to ensure the roident matches the original node, which means CreateSubscrip= tion needs to be modified anyways. So, there is an advantage of reducing co= de if subscription OID is preserved and all origins keep the same name as t= he old node.

regards,
Ajin Cherian
Fujitsu Australia=C2=A0
--0000000000004a0a7e06545b73f0--