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 1wQN6c-001VLB-2A for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 10:27:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQN6Z-00Cx5y-1A for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 10:27:48 +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 1wQN6Y-00Cx5p-37 for pgsql-hackers@lists.postgresql.org; Fri, 22 May 2026 10:27:48 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQN6Y-00000000Fsw-13OE for pgsql-hackers@lists.postgresql.org; Fri, 22 May 2026 10:27:47 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-8367df48711so3105667b3a.1 for ; Fri, 22 May 2026 03:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779445665; cv=none; d=google.com; s=arc-20240605; b=cd4k/gjegu0s35Q2pcjs9cI4Qz1mo9Q3r92DkOe/A0xl/UDNldKcTwdDSRCR/VGTGD T2TpBbZKSOqM4UPkwSDYW7BENrYbqW26L+tlClhxOFh1YSdsiHS+HA2Elf7YvCecVeCA YzEKJR22WwRz31Mop84FYI4QfdvJpArU+TL5Uw0fpQe0AjWyxdnMQPY2yF6Ah/J2R4FX 1s4QturcK5Lj54c87uOeYOTd9vMg3J+/hMZaHOgql63InjM2BA1w9RjhdtT+xzajqhbR qxTpoEvhkgwYsh06USQ2SGlRagJ5iV0FwcGd+8tNRy5oWQoiSHhgRfD62e8Ck+E22Pgy 6Exw== 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=zNd4fvI1WWkt+hp7bAzd2R0KKytRt6Bx1qgjh659Kw8=; fh=S8QRO9UFnSzsZv44KJop5LCfsU0NAh7UqDyZxaFhq0A=; b=RuH0CWCodnNJGjAaPNbC+L1VbNBoLrs38JmEosL6bhFpW/juN05w/5ssZ1Wvuverxq flxou0VCc9E4f475BlVF82vu1WKSVhdEhbuvQiey/zCmH0BQBTCsTq6yOZkVYMD94NsV UepQX3ftNie4tEp13B7eqKqON8iVsnbgf6wULN3akW3oWboDDPB40yMBDDIiznBRWkAL RlRIL+GO5NgEAoBaV9TVxMYOIPLlsD1W+em1UcgZ7nuVKUDChVFJmKbcbUJTqGFq4SNR 6pQkA3Sf+hnSQparrCLLMXOpwL4XeefaUy9TZwEn9gyCAV5urfBslF3T16vIwlMvTPHK 9KEQ==; 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=1779445665; x=1780050465; 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=zNd4fvI1WWkt+hp7bAzd2R0KKytRt6Bx1qgjh659Kw8=; b=lfNB7vRnz2Iit7g5i0fhDDgVGVzGhhhuQGjnPKMGUdj6hF6eWKMtxqJ9Vj8hhi18Jg gikMChM4C3ItVK8qy8MuEYZcWTw6sBqmdwLDzlXXjproOhY8zTvXwghrYuxkbwM5MFTX r0gCcUOzFe8MWvLlE76/1NLEoAQClg1676fcX5SIBB2QwQHi1CkCe//XdMmjjrj1gTSu M+O3/G1yqleP/GGIn6vCwN7aPahz9Ru75EnEJBujbv1vSvQESCDdNHapkXsZFAepEk7M JswI7FbCdSKNGjZ8e1JLa/P36/f1vyA//R1FuTZBKV58GIrKQsn7WjZo5HKUkzUJp+8+ YQBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779445665; x=1780050465; 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=zNd4fvI1WWkt+hp7bAzd2R0KKytRt6Bx1qgjh659Kw8=; b=nKaVCAbeCZ5fQ0BdVKEErecoFZ6pE7+BXJ2csLgKijAmF9buzy3k9XhdkvK8MWFw0+ 3QkVMIX+rsGIhKLzRiQ/HuY3DVhmkbaf2lEvk7pZ/4JzoHuA09cbt/EvjFL7IEIjC042 SQDMk90Zy1Jl7COLUKDfeXyCff1lxTkga9uCXoWTtP9oxu36PgeQW6JaFkLSoBDtbu9/ zE24AtqORKLCRhKoRj6SHrPtyz1LTE5H1b6hSuofN3yoPPthYBf7L1Qnmc66mBOwUaY3 gTnBVmMkkvm5SFiWTKr3hsxIP0nIhFORobp9a4ICEIcWqMh3FzvQCkh2frLyQBEWJ4E7 rTEA== X-Forwarded-Encrypted: i=1; AFNElJ9Xhto06DasLrJ+8HS2qHXDr2FbvXc8SdCcGoS8dRCK+EUhI8Sus/aTm7Wu2p8OTKP0ja+tyW3JTThZBkGT@lists.postgresql.org X-Gm-Message-State: AOJu0YzziLNb7PeNdcxmSjC8QeiuSefEQ1Vo5kMmobo5UltNbYYcuo6c 86MSjG9xvXTpcI5XNvgvok2IFmg3kLJkZpDXvmhqyRDsoLzu7CktcUU5mEJYlOUchlIe+89O5uT 4vumbR8ryqGDlo9vbCy0FuIEWP17cpeE= X-Gm-Gg: Acq92OFAhXHpCekiTkOZlIOhlXv7xT75qls1eBR4Zn+UD+35R/CkPexLaxPmgov2TBR IZDgASTAY5v7KSJxjJYAY+bClILV9SChV6gchI9yBfgwSLivNvtwS4u4fNJcgr3/GA825KdPxXg bCCVxPtbY3Fgkd4qzrz+pNd7AMAX69hxLk+vd7Ru9vkW15wjtlI4Abn0YJikd+fTTWMMKYGCQU9 n3c3TYeEoWd724lmglBuaqzZPoFBA256cLpnx4CDUdOObKLgInIHuyZjo6t3umtRZ4dfmIoNbbU jRcwqpLhBcPweodG97hxbqsN+evdJwXM7kqGz4A4wnUPgoRmbYYNiiXRka2DiAkv X-Received: by 2002:a05:6a00:2308:b0:837:80a:5ab4 with SMTP id d2e1a72fcca58-8415f585a5dmr3269482b3a.44.1779445665144; Fri, 22 May 2026 03:27:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Fri, 22 May 2026 15:57:32 +0530 X-Gm-Features: AVHnY4Joijytf7kQtOOPpYWpPwK4Efb0L2zYpYYaoLpoOJYKRZNToaS7stYOpUY Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Shlok Kyal , Ajin Cherian Cc: 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 Fri, May 22, 2026 at 3:16=E2=80=AFPM Shlok Kyal wrote: > > On Mon, 18 May 2026 at 16:13, Ajin Cherian wrote: > > > > Rebased the patch as it was no longer applying. > > > Hi Ajin, > > I have started reviewing the patch. Here is my comment for v6-0002 patch: > > Suppose we have a replication setup: publisher -> subscriber > and we are upgrading subscriber to subscriber_new. > And if initially 'subscriber_new' has a replication origin, upgrading > the cluster can error out. > > Example: > We set up a logical replication between publisher node and subscriber nod= e. > > On subscriber node: > postgres=3D# SELECT * FROM pg_replication_origin; > roident | roname > ---------+---------- > 1 | pg_16393 > (1 row) > > And initially subscriber_new has a replication origin: > postgres=3D# select pg_replication_origin_create('myname'); > pg_replication_origin_create > ------------------------------ > 1 > (1 row) > > postgres=3D# SELECT * FROM pg_replication_origin; > roident | roname > ---------+-------- > 1 | myname > (1 row) > > Now, if we run pg_upgrade to upgrade subscriber node to subscriber_new > node, we get an error: > ``` > SELECT pg_catalog.binary_upgrade_create_replication_origin('1'::pg_catalo= g.oid, > 'pg_16393'::pg_catalog.name, '0/01743078'::pg_catalog.pg_lsn); > psql:subscriber_new/pg_upgrade_output.d/20260522T140312.807/dump/pg_upgra= de_dump_globals.sql:37: > ERROR: replication origin with ID 1 already exists > ``` > > This error occurs in "Performing Upgrade" stage. Should we add a check > in the "Performing Consistency Checks" stage so that we don't need to > re-initdb the new cluster to perform the upgrade? > Maybe we can add a check similar to > check_new_cluster_replication_slots(), where pg_upgrade errors out if > the new cluster already contains replication origins. Thoughts? +1. I had the same thought while reviewing the patch today. We should have it unless there is a reason we have avoided it?? Few trivial comments: 1) +#include "access/skey.h" +#include "catalog/indexing.h" pg_upgrade_support.c compiles without above. 2) + Assert(!OidIsValid(rel->rd_rel->reltoastrelid)); Is there a reason for this sanity check? I generally do not see a Null-Toast table sanity check after every table_open. 3) + + /* Dump replication origins */ + if (server_version >=3D 170000 && binary_upgrade && archDumpFormat =3D=3D= archNull) + dumpReplicationOrigins(conn); why the check is for PG17 specifically? thanks Shveta