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 1wZ5XW-000lRT-15 for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jun 2026 11:31:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZ5XV-00BiXJ-0n for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jun 2026 11:31:37 +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 1wZ5XU-00BiXB-2k for pgsql-hackers@lists.postgresql.org; Mon, 15 Jun 2026 11:31:36 +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 1wZ5XT-00000000T7e-2Rwj for pgsql-hackers@lists.postgresql.org; Mon, 15 Jun 2026 11:31:36 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-36da151a152so2225091a91.1 for ; Mon, 15 Jun 2026 04:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781523093; cv=none; d=google.com; s=arc-20240605; b=FYXbsl1REI4h9FytZRXMi0opYisk08q+LhxQFbjtUKnTfR4vM7ENBbHs7J/yN1Jb14 yOMidVNU5BINH5OEWQkCWU341dwY3re539UYicXlQwC700YDxCfBsDS23PlqAhKpV1wo 3RNQTYpHkZzQ01HnrH9+Mtw05SBfipqpYTUOv3XbLt8gB/KihNkAyps9TCwi6mHWVL2W kcJfY++X3VOCO9M1UdDo+GJrrpGlKVaqxUc5EcNLXeZNsZ3H1bEEkqSq9GBxclIesdVW RVd2tq2oKwydeeDEEC1gAf3STaA+cNRyjiN1DjirCCMj0EEm/dqm5sKdBepQbDTeJS9Q dy6Q== 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=H5CHwIrp3pZYpvHl/u9CJ3L0FTx0rErFp7S2sr/brgM=; fh=jqKZe0GjEZlYfkwBQ1d7NTlQJujIr5r0dkfMHB00JPE=; b=kZKkGjA4mCbEfUQJCW9aT4MYK+0ym87GrLZsaE26QuXB/u/nS66NfuI8dJXZLvuw1X j8eUFVwu/5ngtlftEZVcmper9893giI5ZfGT0vqu3WnkrFbmxMc/vqdqcMPGmyNtt40X eGKTJc+G+7MMnMbzT3u03JjwUCGj90EVfh3Dv/6Ux1D5IN2ipNeYCMsydwrFP6CvTJ4N yTgkbngwNPKL8Sofo6VJx/ztzhCZkpa0vsbVL3Ja8HVbDfmVBVvKG6UhV3d3jbBwY7Vz pwp2hMYoS/kN+BprFyOexUStf6L6qhhyvfL8nQuJdc/ROvUXy0/x2czv9w6+C71Qb/Yl oHVA==; 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=1781523093; x=1782127893; 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=H5CHwIrp3pZYpvHl/u9CJ3L0FTx0rErFp7S2sr/brgM=; b=pD/Qz8C/czbaxX+Cq84qG6o23AuRZOayJnDOUNpAU3YMie3qoVRl4oLiCl07gYmZ8a 6jEeeHVaxlWqbgNl9SvI94wOCvJ08kfum+1L82rbshmFjfL3eAjjjvocw/cp13K35wUK N8230bFfNYzym1VZNQ34lyZ5q0+aZALaFuEmqailxx8om6fjW6VEcfIktxMFZyUdRPJt uIoMYJRxDIUM5LwE6fq1yA+z3N4TitI/752W8KX9hlUgbjGlZgu92qCnt0BYyS4hOsXj IrPtkxBnCp3tJvk/MU5drbWWWtwCfTzulopPKZCuQIKycjoilUO9MkJTqe7hhITvTtAZ jtIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781523093; x=1782127893; 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=H5CHwIrp3pZYpvHl/u9CJ3L0FTx0rErFp7S2sr/brgM=; b=WX1GyWn//VoFvwyz4Xnw5qKVuHpQMSHvE6c2PI04iaeoX7tVicTIjvfwLlzgzsJPyZ zQZTw4kW63qGp87TXjyL+Hqzh7ICU5ClAUcyLy8pwRowggYp48ZjhgmJHSptBNx1XsnY obqdmVU3kkev0TvhNZr2tNwgRnKIJmzvUiWlDXmWOJceSCQQrwYsYN6mFjv2Y+QI9Yyv Y7te8ppSw2lELSWqZpSGESUJwIpBsa/J7lb1jXkRtcrvXER7Xu0FqDq80WlRLGe6/emh BJcHt/fZF+52DswPasAutM3eTbDSo7cYWWy8Y6HLw1AQKHNh8tg7kdZVW+7Y0PGqj7Nr q/Hw== X-Forwarded-Encrypted: i=1; AFNElJ9lFDTRWbInwRLoF7LXNLxdf7CE2Gv7q7HUUXCgmsDmcyuLZgB5lVFmcHoucTorqbHpmTvws9QXxZdwDnyx@lists.postgresql.org X-Gm-Message-State: AOJu0Yy2XOXJitt6EOIyWPm17WDhE8moxZfmBzLeej5jcWALPp/XMKs4 xAocLbo/s1LDufpkYm2jFd8wzqMvVHPFmYmSoed/Hh0o7XJb+6UWdH2J9QBnNqJCVrRCxEHxaAp KJ5Acyi/1M+SFPuudx8aYCyLV+B7Udfs= X-Gm-Gg: Acq92OFJ5Pxasd5tcY8JUrOokNJ3XsFzJzDM8vDknKjtlX+tQKamCNRn9UcCo5WAgTa sJ7X+LWFu6rVIal0htwilKFNI6qxMDNScFf6+u5bIZ1cEPmcj6VAO4uy6khsYE/SrCUprmrfjrP VjXfYWbLZ8HaxBFTCruewsKsMa6u9MrGnTwYlNR9LjRwv1mjpY7UcdOmbKYN5yRATRPdcJG09us A9DDMcIeXkQgqEELDNuLB0nxv9WWrS7A3hs97JBZZFleAdH/arviDTKexckfcetqNYoaJXVVO7o +7lMwUpWPvILcDOT1bYdjshaDiUd1YjGH902UaoZgbJ79r4GHV61b7D8YHY9M4x0NjtXSYut60s 0NC5upDA= X-Received: by 2002:a17:902:c402:b0:2b2:ebed:7af5 with SMTP id d9443c01a7336-2c66416349bmr127891525ad.13.1781523093185; Mon, 15 Jun 2026 04:31:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Mon, 15 Jun 2026 17:01:21 +0530 X-Gm-Features: AVVi8CejEKTH-NWhNlWNL7RaZ1RhU3FHZOG6RANqRWJtAXhmRINhQNK8vP1EuHQ Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: shveta malik Cc: Shlok Kyal , Dilip Kumar , Ajin Cherian , Zsolt Parragi , vignesh C , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers 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 Thu, Jun 11, 2026 at 12:08=E2=80=AFPM shveta malik wrote: > > Ajin, Kuroda-san, and I discussed several possible approaches to address = this: > > 1) > Add a new subscription option, for example 'skip_origin_creation'. > When set to true, CREATE SUBSCRIPTION would skip replication-origin > creation. During binary upgrade, pg_dump would emit > skip_origin_creation =3D true for source clusters running PG17 or later, > and false otherwise. > > However, this approach requires introducing a new user-visible CREATE > SUBSCRIPTION option. > > 2) > Another idea could be to have a > 'binary_upgrade_skip_subs_origin_creation' variable. We populate it > during dumpSubscription if 'source_version >=3D PG17' and > 'IsBinaryUpgrade' is true. So this will be dumped > > SELECT pg_catalog.binary_upgrade_set_skip_subs_origin_creation(true); > CREATE SUBSCRIPTION ... > SELECT pg_catalog.binary_upgrade_set_skip_subs_origin_creation(false); > > First call will set 'binary_upgrade_skip_subs_origin_creation' which > will be used by Create Subscription to decide to skip origin. This is > similar to how dumpACl decides whether to record priveleges into > 'pg_init_privs' for objectes created by extensions. See > binary_upgrade_set_record_init_privs() which sets > binary_upgrade_record_init_privs which is then used by > recordExtensionInitPriv(). > > 3) > Create origins and preserve origin IDs regardless of source version > > The current patch preserves origin IDs for upgrades from PG17 and later. > > One reason for choosing PG17 as the starting point for preserving > origin-ids is that complete logical-replication setup migration was > introduced in PG17. Prior to PG17, subscription state > (pg_subscription_rel) and replication slots were not preserved during > upgrade, so limiting origin-ID preservation to PG17 and later aligns > with the broader logical-replication migration support. > > OTOH, replication-origin migration itself is supported for PG16 > upgrades. For PG16- upgrades (without this patch), subscriptions > itself can be migrated, and corresponding origins can be created at > that time. Therefore, even on versions prior to Pg17, it may also be > reasonable to consider preserving origin IDs independently of the rest > of the logical-replication configuration migration, and not tie it to > the PG17 boundary. > > If we choose that approach, check_new_cluster_replication_origins() > would likely need to run for upgrades from PG16 (and prior) as well. > Subscription-ids also need to be preserved for the same versions. For > reference, check_new_cluster_replication_slots() and > check_new_cluster_subscription_configuration() currently run only for > PG17 and later. > ~~ > > Given the need for a new user-visible parameter, I would rule out > option 1. Between options 2 and 3, I prefer option 2, but I would be > interested in hearing others' opinions. > 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. 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. --=20 With Regards, Amit Kapila.