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 1wcFrR-003Cuz-2n for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jun 2026 05:09: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 1wcFrQ-00FNoe-2W for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jun 2026 05:09:16 +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 1wcFrQ-00FNoW-1U for pgsql-hackers@lists.postgresql.org; Wed, 24 Jun 2026 05:09:16 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wcFrO-000000022t6-1ak9 for pgsql-hackers@lists.postgresql.org; Wed, 24 Jun 2026 05:09:16 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-8454c5a280aso1013996b3a.1 for ; Tue, 23 Jun 2026 22:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782277752; cv=none; d=google.com; s=arc-20260327; b=WQt7FxwgRO5vIFc8yHaNXOHQZc2HNty855eb4ID3A9Jz9fYvjkRrlHtT/cnvENgDQ2 6+Cb2EbLrCTFcdxHFzEXVQUpqmSm+v9vc/KOXCQIMEQROwe7GSJzTGgA8dkW/ry37r2z 61B1WbXGYvy7wOoJSUJ2EAGc2AANR0c+LIushIlwEnoNoxlxJxoyo9yHELy994Fcny40 Cs7A6Q4uwled+gOSeferQM/CzlT8rmJNepSntEp0v0vfY1i9F+Zf8NGUrIbwvFvWeIvd Qu8d7b0quHBMfaJRlZx9mDs+6azKH8n838CrmmAAk8tyANyM7BJAjq/yzyBiKmf2l3Ac BbHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e8Ug5CWw2HmkLB/YHMeEt8HGtQeuvYSO35nDvmdIYFU=; fh=SlIdg7Fm9zRVXwdSm5b6jH9a6Bq4p5HtBh/tuyKP990=; b=R9CD9n3TeE6GoHo83IvaoXXYhTDSvBdkUSBnaDwOHLfIUiMYjbxWcn348iupGJMLh5 KTKvtCj9Ki4mHwG/RsIaXVWeITUz4n+O6cAHFzIqWe3GS37G7hxBOq10DgImyPxl+Qj9 83JCwrx3qzfa/TpwetP5HZLjsw4yR4ZmASX3LeftUz7MZwPUcy1W2kRWlCblaLNLdZBS bOSYWmckKX6lSq0PiGQ4RX/EGU5O4NK8bt1/vZtZ+OOtQ4mqGUD4RdZbsYo9AWibykvO yXqq9cYESbW3Y1KyMeeE8q88KJBmia3Bhqii7AG+bdt7LsxQZvb8rkpguHE2VwrOubFr QKgQ==; 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=1782277752; x=1782882552; 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=e8Ug5CWw2HmkLB/YHMeEt8HGtQeuvYSO35nDvmdIYFU=; b=A2Q3dS56xZHUowTuNkkL5Xbi2GYZlmqYESOpOjpApTN0XVjF+2s/WrQSt+jexhPPSE Wt4rrLcYw6IOzQB0j2vZ4cKL2gZBfm5Ljpqwu06rXKytzAc13vMPiIgODvCPNWjxzwUh ihmUiPiHPJBMz0onHh3EK1RcyqNc/6wxjlpjahCjJ2xIL3BxyF6ZAAXHJOx3dUirz/d4 KJmpm87QjRVW7Q2b+12f9/jswnvkgK1oZhwfFyTHr9UTqyNTpKhNn6Ct1BgolF80yRvL CNqktDVY9b5MYPCG65m8heKoIsiQkbFObCwThnopBkJfqIcaN760Dn9VmtKP9hJLnJwf ifzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782277752; x=1782882552; 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=e8Ug5CWw2HmkLB/YHMeEt8HGtQeuvYSO35nDvmdIYFU=; b=D922gaaiRp/bjGYUzcIIyoJwkcX5KWyE8ARqr3IoUjwMV8bTjHrtMaNmHcKK1dbWyA xWjt+kRVOx7KJFty9Bmnxx6i5sQUVkoLmCvH5CrEXky+xaMYp1Wgw1gRNElfcV3QOe5J jQpHJmDQDNKh3B44rKNmSqBpBHyTWJgL2jgoWtrPGaRCzYckTqqCI1sHp3iVedyFaBH3 hRHOYB/fmRsX7X/G44FV4Smcy4iq3liKf9qIQt69TjLU/mHPcJuBYLLarvoEARkckbVC 5RYY/ZmZXD3+Yp72rB4St6yWcjLYmUoEI1tUFcBd1snzWdRUBtMSFfsGXNZn1dNKUwO8 cbvg== X-Forwarded-Encrypted: i=1; AFNElJ95gVyYZMBf7k5Bv5GNV1h8W+ejzCOKJ9YIz8dLeZP8y1HkvBuLkQJZRW4ruBVCK2zqQpxD1gFfJk504Nl1@lists.postgresql.org X-Gm-Message-State: AOJu0Yz+6ZZmZSl65/Ma8wE8rZCAQcFGCBy9h6pqZ5fZXDTIf6fH1BzK zSEcjThR3TmmR+jTZzowvG3shMErYHcVumaej13F0cYAcBapMPbwtAif/wcgsk3QyEHnidVwM2E CZr7Wla/24HPczTQlL4g2WtwfQQia6iQ= X-Gm-Gg: AfdE7ckhH/ZP1qOgG+Gact0xapRyA2/0jeS7rm7Uefli4692bcFBEofBnO5PDwTkZnV Y7VGZmYIiNnv+q0z2c3p1WEOL+FZmS+Qq0fBXnT0CgNsuK+wwBWB+YfhNYBGLe2+YH6Gp0bIl9v pWNfw7vLGJm3PXOKW3t6S1KMA+jli+Dwd/Oo9kDoCWd/yaMznYVsQGMNKPrv3y74ZLQVihaWvcA 1E9XH+7F7S+CtMPhOimxxJfN+n4kUaR/+dZW19h42lInB1xYFUwQO056VXGSwZWP+zjNgoesGsn IHd7SC+dC/oLT8tWUxg3BBJqGinFU6DbE2ZrrO4i X-Received: by 2002:a05:6a00:94f7:b0:842:446a:4cb5 with SMTP id d2e1a72fcca58-84591a0e8e7mr5954552b3a.0.1782277752478; Tue, 23 Jun 2026 22:09:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 24 Jun 2026 10:39:00 +0530 X-Gm-Features: AVVi8CeebIehu90KhWuqx7KnEQCTj-gC4G8uia2wZCDcJSkjpvZT2JfsIqExWX8 Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian Cc: Rui Zhao , Shlok Kyal , 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 23, 2026 at 5:20=E2=80=AFPM Ajin Cherian wr= ote: > > All the above changes have been addressed in patch v9. > Thanks for the patches. A few ocmments: 1) + * In binary-upgrade mode, skip origin creation here. This is required to + * preserve the roident from the old cluster for this subscription. subscription --> subscription's origin 2) replorigin_create_with_id(): + if (SearchSysCacheExists1(REPLORIGNAME, roname_d)) + ereport(ERROR, + errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("replication origin \"%s\" already exists", roname)); Can this ever happen? IIUC, since new-cluster should not have any origin (as per the check introduced) and old cluster can not have duplicate names, we should not hit this error. Do we want to keep it as sanity check? If so, can we put a comment atop it. 3) replorigin_create_with_id: + if (remote_lsn !=3D InvalidXLogRecPtr) + replorigin_advance(roident, remote_lsn, InvalidXLogRecPtr, + false /* backward */, + false /* WAL log */); We do not want to call 'advance' from regular 'replorigin_create' flow. It is only for binary-Upgrade flow. Do you think we should have a sanity check here? if (remote_lsn !=3D InvalidXLogRecPtr) { Assert(IsBinaryUpgrade) replorigin_advance(..) } 4) replorigin_create: + found =3D true; + if (!found) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("could not find free replication origin ID"))); Do you think we can make use of 'collides' itself here instead of adding a new 'found' variable. We can move 'collides' outside of loop and use it to emit above error. 5) binary_upgrade_create_replication_origin: + node =3D (ReplOriginId) node_oid; + + if (SearchSysCacheExists1(REPLORIGIDENT, ObjectIdGetDatum(node))) + ereport(ERROR, + errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("replication origin with ID %u already exists", + (Oid) node)); How can we hit this? Same comment as #2. 6) -check_new_cluster_subscription_configuration(void) +check_new_cluster_replication_origins(void) - /* Quick return if there are no subscriptions to be migrated. */ - if (old_cluster.nsubs =3D=3D 0) - return; - if (old_cluster.nsubs > max_active_replication_origins) With these changes, do we even need to capture old-cluster's 'nsubs' in get_subscription_info(). I do not see any other usage of nsubs. Let me know if I am missing any case. thanks Shveta