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 1wRPVU-002K14-1s for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 07:13:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRPVS-000PuW-1V for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 07:13:47 +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 1wRPVS-000PuO-0G for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 07:13:47 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wRPVR-00000000fJA-1rHw for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 07:13:46 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-836ebdeb969so4193631b3a.3 for ; Mon, 25 May 2026 00:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779693224; cv=none; d=google.com; s=arc-20240605; b=aethktLW1EYoH0RsLJw+dz9vMg/JT/UeI1GEnuOzTqIDvLW+nqLq5XlqqblHm5xmBt 5frTlFSTnt9GB8tHE04Ai9zhbLLCf6CiUHKfnsp2RpOA+zWPb7F8tfENrhUF1eJAP/f+ oA8KlD1cMuAxkoVafRdmrAwIvunklWyX91o11SpxAzBpzI/3dPQZZEllq9FutcY86kZX UPtkI6y218eNkheFoqE1PApp89KfsDn1tvwj7GpDc5dwC15JJzBzk/QoTxi1X6aW8e0e zG17C3qpPQduuX2Vj+gol1GbNMZYktU3zCh5ZTJX8OJn1XSHm6GNqSt5NvOzpVxU3u/d IKLw== 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=w73Kn3ZzwFIwJpr18DcmAU0zS0fQpKU475rGF0kqjyM=; fh=a4QFliX9ZzgIuF3dC1Fq9flUIpSgwDXntpNeLxBTmvM=; b=g0uQTZnmXyLU+JQDrVyuA5Sf26/2LItEKtiJX6qmCQHZ0EiKhj+s1CYKzqaRywoqEt EewD3FoEJwuQxVXzHTSTpaUQwQGQ2FLpnzG4omTpIPdel9qvMgPP9JJwUzo3khYe19kE X5esxs4GL5LJoVwphthGxOnCHdUX3uAvGavloZznJ6HbT5faM7ACC8udR7mEtUBL1684 MCzpjd0FUmJBsnFUqXvJQ78Cwr9CrCQCqEaoHa4hO9ENtYSgDY4wyYXjX0CXnUGo3xWD rI+tnxIQCoxLsw5xHamCWoC/YsW9Fw+RXv7NPhYZE2UH0L32SM0hUHA5wq/nTWKWj1VN 5LJA==; 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=1779693224; x=1780298024; 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=w73Kn3ZzwFIwJpr18DcmAU0zS0fQpKU475rGF0kqjyM=; b=LvXDblgXZnb/wFL0ol9Wfu0LRIAX4gM8proSX/uSZQ+4LcmGC99GhNMGuCLJKRFOID 4hXEmbfrTYu1eajOoQ/vAMv78BjTxSsFllVcqv+F51KiQjhTgVV7zydBaQnWByutG2Ba mhXgUqQKg3CObIa83mfLoyP9c6hDmU0gqHhzZ7R/AyqPCs5QRl/ZJ2KvxSy9nqjD7zie wpKQ7Eyqht8gOBav7zIlSO6iAcewhtzHTi17ToWe+5WziN7u42gLfYjVSX4X+JYQof/A 4nBI6QwRoc5stA35bIw0wRGKuQb/j1F8g0H+MXNsiMPu/H6NbUnjXJdrtakqJ0KMrsNc Eh3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779693224; x=1780298024; 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=w73Kn3ZzwFIwJpr18DcmAU0zS0fQpKU475rGF0kqjyM=; b=WoNDj4jUuYMFNhZlvAbwzPj2luQ2xqTbgPQRipGgwyhtji7qOvqa6YfrXHl29BBZy9 enYHZBWiNgapG8xaawxt+jY6X4R72cg5gYn7BkmMrUPqAiP9Gr5LqeDTnr9nBji38H+r 5X+FCE4wFRNbmutHuHjFr4mQxL/YlyE0ktD3YsgpnZsXk+pSzFbJIRVUuD98OK9TCrE7 jzXayangPax9wd/cimauGTcuux9WJBJCgN8b7ax0rcAKUwtZkwQkhh+q+QUsV6doUySg X2Bgwc0IxDZ56QjV1X+RrJrM7goXUZmeKlklu0wE4kZf0xWZwPyV3epsFOOQfrcJ2gSE Ebvw== X-Forwarded-Encrypted: i=1; AFNElJ/ACBGzjX4z3YsWpZBG1HQyOu2HS5YsHe+0m43slkvPGbCYki07dpYPcep61Dtm1YHzNNZpTeqKkru/XMbX@lists.postgresql.org X-Gm-Message-State: AOJu0YzkD3lN6UXbP/GcLadFhxPbKvLlrjsEPkFzurbW3spfYTftEGwM E4U6lwb0b8mimIwtHi2r1fEn1Hz7nGd/ooJrDvUxJ+SQGwxPc+hlime7u+L6FWwxN134n0SOxXP O+ImDuqu5/YF40Y6TCNyOc0hG38GFz1I= X-Gm-Gg: Acq92OFmWORFDvtidypFgZaR75xiUnTn7dyJwDIq0FGtkH1oboJBzcyFuEEopgv140h YehDRHA6CAfy+nPzO9+EkqJCmMJ5qCUCNv0w0P1RbQjmMMgJmnV3utW/J+u09EAfPEHW1AoIj/t HQ5dUXuUhAHRjPO1p6ODjL5AEDR3UAk5No1ZydQs4wzlJ5QBwmILCVQSiHIPkS2CeeQOYTUMozk ARdJxGIz21I5bOAtfWvNbbeWUy3VHn/gCZ5mLTLpFM5nXx6eoDnXrmReGSOa7/L9AEiOgv0sKNg qD45xa9Qt0FDiUVQmOpw6frHtY5bvvMrk/QqjDlFMdRqKDwziJtHnA== X-Received: by 2002:a05:6a00:8c10:b0:827:32de:d197 with SMTP id d2e1a72fcca58-8415f37d792mr12133332b3a.40.1779693224394; Mon, 25 May 2026 00:13:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Mon, 25 May 2026 12:43:27 +0530 X-Gm-Features: AVHnY4IguwI8OKxLAgOAHIceTMe_PIgvBqDYgOMPVIboNXkqfiMpErGXqKdADek 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:57=E2=80=AFPM shveta malik wrote: > > 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 patc= h: > > > > 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 n= ode. > > > > 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_cata= log.oid, > > 'pg_16393'::pg_catalog.name, '0/01743078'::pg_catalog.pg_lsn); > > psql:subscriber_new/pg_upgrade_output.d/20260522T140312.807/dump/pg_upg= rade_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? > One issue in 002: binary_upgrade_create_replication_origin() has this: + originname =3D PG_GETARG_NAME(1); + + roname_d =3D CStringGetTextDatum(NameStr(*originname)); + We are getting origin-name (text) into Name-type which can not be more than 64 bytes. So if an origin has name more than 64, it will end up trimming the name post-upgrade. I tried this: Old-setup: postgres=3D# SELECT pg_replication_origin_create('this_is_a_very_long_replication_origin_name_t= hat_exceeds_the_limit_of_64'); pg_replication_origin_create ------------------------------ 1 postgres=3D# select * from pg_replication_origin; roident | roname ---------+-----------------------------------------------------------------= ----- 1 | this_is_a_very_long_replication_origin_name_that_exceeds_the_lim= it_of_64 Post-upgrade: name got trimmed to 64 length. ------------------------- postgres=3D# select * from pg_replication_origin; roident | roname ---------+----------------------------------------------------------------- 1 | this_is_a_very_long_replication_origin_name_that_exceeds_the_li thanks Shveta