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 1waQOi-001n9D-1p for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 04:00:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1waQOh-00EuJw-0f for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 04:00:03 +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 1waQOg-00EuJi-2S for pgsql-hackers@lists.postgresql.org; Fri, 19 Jun 2026 04:00:02 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1waQOf-000000015HF-0eIA for pgsql-hackers@lists.postgresql.org; Fri, 19 Jun 2026 04:00:01 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-37ce68a54f8so1057257a91.0 for ; Thu, 18 Jun 2026 21:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781841600; cv=none; d=google.com; s=arc-20240605; b=Nr4k3aagm6fKYfPAvGtuzsIsXzxXq7//NAZ+zqR2Wgcw+xMnIEzCx2m4JHLjjdKBy3 EmtXFP+SfUDkIq+1rlVcRksq9vOWPqJQNnmhEsHnth7ryGhzOVqQ9YHomqlfdyDV00tp f/j+4lewU9+lSPWX32vEbOAAFOA5eQcICJgja+iojQr0H2wvonmIf0CNpxxMl6PbwjfD ZHRqfcb+fXcBZvuE41MGBd/Lp82DSnG9psCD/x32ToW017Ly9ar1jnROXCsXyEqEllp6 JyWx0q9brIxSFIJHFXt53XhrDvdAY0rWwe5/sGQrTY7pdLMvyIqFNAq2SoF5S6/CbQlr +Yhg== 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=QC6Nek5/YHJKsRYdMwi/KmskBocELYGK76ZZs2Nn1Dg=; fh=4+lFApXIw1fCXSicmgXQzgy9liEvKycRBnFDecpWmQo=; b=HfpL1Dkx+DL8hEmI+RXXFPwWnt/WtXpMxoJpQFZXD/rgO34FHbAjbkXPQd+Mk3EZ+X 7CtDKohU3YRVFebXUM7xuX5iwRdwyrj4uvTsqMKPwm3yTTcg98OrrLoU0pKPmpGiSYBf vhY8qcal27YmOqyNyQFzVmElh/qgiksL4S+xSEY1IjMKZmKm6SUP8Rv25ptREBIrk8iK NW2hWqXjL697kcqY5bb2F1nHwXz1lE+YrWUfcb9lxbc6orBVdGpw7K7APYgQ4SsO+4sd V0k0C6MWBELF+2q3WgF5JUDvKgNX4BWxUa11oWl9mqBvco0E1EaY7YmxZJkr3OokhuDz ja7w==; 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=1781841600; x=1782446400; 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=QC6Nek5/YHJKsRYdMwi/KmskBocELYGK76ZZs2Nn1Dg=; b=VBkiUBK11ygW0MeNpI0bKSoTq4iPutbftOWqhf6NsUIr4jjgFK1Lz10CpBIdOIkK6v V7Sr0u2YAWTtBRZA9LL/qKG7uWag0j28lp4PpfN3+GCpnC6Sk7QBawXJmKSE36pJbBYC BqGKKoauQWO0LW6vp5UMLK9dKMvwGpz1whJlyYcKneX6Aq5aG2ObPYBUTcAwu8o7B0c8 Kp2rmLEnK5CcLv4k5gVNUtON/dOMoxANR6OHp9PgUD+5stt6ejwqSZO6JAAwO6Oe4HXc mGPTcNrO8MyWi87s5K9vcICB98efjNH1j4xCkTytPvVq+F3nFcVVGi453SnDksZoHGeO D0MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781841600; x=1782446400; 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=QC6Nek5/YHJKsRYdMwi/KmskBocELYGK76ZZs2Nn1Dg=; b=VUfougjobyJbqO3Q5X+O9dKsB9N+6Iwjngy1a+gCl+kKnbxNL2cPjHgHaCfsuLbzNm U0yCSGpcGHGCAqusQv3aMby1fzECKSLgX4aSI3n+QvQ/nfMMTiG9LvD86WJeJ1/6Am7J 18YrJ4A7T/84MK2kQTGI5NzwHIHSbAYRJX3a9MTHm/oik1D6BILRNHuGGFwXtt5tOxdT FPUIpAnjEPGmhwnWHqgbbEugAs63o0EF+drIQ+UdV2umIdZP98DJeZbwcP6ssU+phmM2 eOkyCjGSxr7OVDUSpLN6ZyrzGKoIXIYeIs38tkMLPsp2i/hiRhBaRgK8SbdFmh/99IWZ 0Ltw== X-Forwarded-Encrypted: i=1; AFNElJ+4YjyD335ZqKOwauWQchJBQJt6ICKsCSaMgoRCv7B6W0lX3Uc833+qcWdQGHghHzue1aybKzbGGUfINd16@lists.postgresql.org X-Gm-Message-State: AOJu0Yz6Z/hQYNhYpcFJ8BMc+H6bakdSnwdbsc6M9Vd34t0IDR2dnGE4 gPLD3N5KTIQNf1emvQ9KJ9drUGw89j3l5b/VtNd4nrSKCPoxWgisyxN5sMzjS+WaV34hu3VIBha 8pAeKKJ7SzKwmBYlXWld9eCleK1c5A9Y= X-Gm-Gg: AfdE7cnJUXldQ+fl7rBwwlz2bEd7G+dhONHbKr/v7Hkmxe0zDn8IjIUKn6zZtXuc9rx ITjNKh8/OyDH/QjIC1jOOP4iHMn+i5MPUKukSo6toowh5BPNr0jb7CgbCUBHVzVbcZzU7sacG5u NPpTIeABrtE5y/mmo4+AZBuksxW9jeu/rtSUgOpDF3UbDGjM/gBWE73R/rIGfc4kmXpC+QElJsF uH6NxjE7+EwcJLc+MR4cWrm0M4sYOvsnJ6QVKzkPPH/WOLDBKAlAFmqfkzIB76Hl9P/Vwiy3C27 YWd/D9m05c5jSCFjFuCxABHTCic++6kEPd7y6w4OH3U= X-Received: by 2002:a17:90b:1806:b0:367:b819:2214 with SMTP id 98e67ed59e1d1-37d1e8b3120mr999157a91.13.1781841599802; Thu, 18 Jun 2026 20:59:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Fri, 19 Jun 2026 09:29:47 +0530 X-Gm-Features: AVVi8CfIUxXH_n_sXd12Qkcx3D6N-MPg7Q-HTmm1fBAQrjbv6sm4fQMxJr2924E Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian , Amit Kapila Cc: Shlok Kyal , Dilip Kumar , 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 Tue, Jun 16, 2026 at 2:50=E2=80=AFPM Ajin Cherian wr= ote: > > > > 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_dum= pall, 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 subscriptio= n-associated origins derive their name from the subscription's OID. If the = subscription OID is not preserved across upgrades, the origin name on the n= ew cluster will differ from the old one, making it impossible to restore th= e origin independently. For these origins, creation must happen after Creat= eSubscription has established the new OID and not upfront in pg_dumpall. > > Non-subscription origins have no such dependency and continue to be creat= ed separately as before. The subscription code also cannot be left untouche= d: even once the subscription is created, rather than origin being created = inside CreateSubscription, its associated origin must still be explicitly c= reated via binary_upgrade_create_replication_origin to ensure the roident m= atches the original node, which means CreateSubscription needs to be modifi= ed 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. > IIUC, the conclusion (and what's implemented in v8) is: 1) The origin-ids are preserved on upgraded version irrespective of source version. 2) Since origin-ids preservation requires sub-oid preservation due to the origin-name's dependency on the sub-oid, we preserve sub-oid too irrespective of source-version. Let's see what Amit has to say about this. thanks Shveta