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 1wbKwM-002SnL-0M for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Jun 2026 16:22:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbKwJ-003X1A-2H for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Jun 2026 16:22:31 +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 1wbKwJ-003X11-0r for pgsql-hackers@lists.postgresql.org; Sun, 21 Jun 2026 16:22:31 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbKwH-00000001SlW-3gW5 for pgsql-hackers@lists.postgresql.org; Sun, 21 Jun 2026 16:22:30 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-bec450b950dso503321366b.2 for ; Sun, 21 Jun 2026 09:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782058946; cv=none; d=google.com; s=arc-20240605; b=KDF6d7SSGiIB0rUnNBM1pS4NVgA7alVcN4G8MGp/3jeTIqJSXdzbLHGUphmpnB6kKy FA/WzofmAkxfI0uUH7ZyY9e1GWMF9lBcV6skevU+f4WirTeMZbrR3bpXPRdxTwatqAQ0 5P6nUzMJnXChl1oA4O749FciQnswGwiuAmdcwuxzvX4u/W3gPVAfYhmv0NTxJRvtfHth aSzdVeQ4JaXj+bw5aCqfPSTm78jhqcjtPR9ccGEplZmhb+rrE/d9FmVmGA3iaxtSk6YB 5AFDjdGw2vHorR5HwWJvUjxzcyk1wDlrjZBAHSRabZWdxLOgejVT0IdxIlV69HAUYJL5 pGMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=OhRRJFWjy8tdUcEB2WXCbauj1XKi42QLmjeA6hIUzHk=; fh=7OKXE82dnYDfIOnVjZpXvBuBJLg6Gg9LiiwbwmFT+PA=; b=IvDyjRLmb/CxCH9UBr/45eYELbQawaYoDxRWSS6+GRAlBse4QP+f1VJyYJ9xttz10P thkDozyeLCO1qkblN9cfV33FkiBmZNK9KbcSFPe2NFUCt1XNXHvLJPHWA5vGeeyiF1sL rbTXL0bwzRdmeHShL307sPM7flSIgKBs673+/QcFB2V8Z6gPN+eTkfJkCW1RUHFHJ9gr K0HNRvsS2uoTblGEmGqOVyundWm9XLKg0rJRa3cNrioVU8OYkRT0sSZ2iS4+WDYtnDrC PG6SJslVz9ceMv1eXkRrP4tBa8vctJNcAjqFsWysett21AeMtf5iH0rl4jJddaIQ7CVm aeaQ==; 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=1782058946; x=1782663746; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OhRRJFWjy8tdUcEB2WXCbauj1XKi42QLmjeA6hIUzHk=; b=bS9w0OvR8SdFX7Y0Ib2tU0GkfpMKvu7LOVxTYbWiUB4IJ+VxS4Z6ivRTOoFu2D9vDb 8fTsaye/UZ2aATf3fACZdMuear6/hUd13gt7GMEFYXm+c8Il+sqHiQ+aNSJueOfAoCxf Up/iBAg/HO0Y8SB4fU1wn4HJz9ddIQ1b0fNIR6A20uZqNhZ384ANhjIHAk+55niTxDTe d7g5lW9srW2XNgLzsh3iEdciXzVlZibm2XUhG6uSGGSxLoLN/VYlKyzreJ7BeHAlPcXQ AgRZEQGV2rNr1DEDZyI8aN6ZYs3bGL5mZi3hYadmLL6kKVRTieZKW5sGm9Y8fjG2QmXd TsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782058946; x=1782663746; h=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=OhRRJFWjy8tdUcEB2WXCbauj1XKi42QLmjeA6hIUzHk=; b=i6Awb1/jcuFkBgbM2SaRmopDo0p89HEjgN/YDEv3rJmaIQ0jAML26gx/um/TKrWYG8 5bvyaTQxfa/wQqDdrZOGjFsaMykCjwB1ajhJResLdZRmb2J40mqRRdClxHBYihlZvy7x P4hdv06gP1KDughhIgN+jUj919RZ4/7p0iWAVMQHcJ12qghwA2pPjnpelexOwOGuGO8d sD7h2qiG1wGlaAn7eyIjEiNEMg/AmIscUcdIs3FBck6VIofeX8vOa6BPfd94z/nTKVDB QClI26dgbpWJoU6qDkXNQM+rGJQ9KA/x+hoSffNEFknpbt/CQP7AHsmfEl60SWXIS8ek sDdA== X-Forwarded-Encrypted: i=1; AFNElJ+QTcLoXty6nJAE/zlbXT0HbT6RPc7l2dzG8JoC+ue92BZRrjUluAXAQBwGVYM0sMJZlYcWX5pt94tb+vR9@lists.postgresql.org X-Gm-Message-State: AOJu0YwdjGsGylw6ZMBxF9GKQ0IyzKgAZdMCwO6tSld9AC4MFFNittvG 75NRytLTzFqvkuXTrjmosgfEYxqqyWXTMhlAnMpKk3NFsLzfi/m1trmH+fFjfuFwzljxFlZrF7A 3YANpByS/qkXo1/OvZHRMITWy7vVRdCA= X-Gm-Gg: AfdE7ckB3jimDcV6hPy5agPEqKR2FsFUcGo/xLFrizM3+uO4BJxWaNhbNwpvo26dx31 ej5pooceDRxfXN1cep7oxwLh01HbgLt4mvUfJOBkErn2xTZuiaJeB6H2LiWj/d4R5gWVEQ8xjw/ fc+l5L++GgG3UVa3PEka0b0e+LKct0ZRPZeqv4YjXvZEovwqLbtolMXwYhy7jlDQIW81l96/C2Q pnHh8ZxiDkl4K9TaLflpL3gnzu7XV4Ec9wGuHSiWRufrWGdSRb4I4HBkd+E4NDMsgg12cA= X-Received: by 2002:a17:907:3ea6:b0:c08:59dd:3fea with SMTP id a640c23a62f3a-c0b743b0349mr485930566b.27.1782058946249; Sun, 21 Jun 2026 09:22:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rui Zhao Date: Mon, 22 Jun 2026 00:22:14 +0800 X-Gm-Features: AVVi8CddT7eVsPBjvel5VOWYexMOaGNWHe-b2oSFQwZJ6Ff5mkewPsfNkL4KOz0 Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian Cc: Shlok Kyal , shveta malik , Zsolt Parragi , vignesh C , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers , shveta malik Content-Type: multipart/alternative; boundary="00000000000075c9480654c5ee0e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000075c9480654c5ee0e Content-Type: text/plain; charset="UTF-8" > > Hi Ajin, > > Thanks for v8. A couple of comments: > > 1) The PG17 gating seems inconsistent between the dump and the check now. > dumpReplicationOrigins() is called unconditionally: > > if (binary_upgrade && archDumpFormat == archNull) > dumpReplicationOrigins(conn); > > but get_subscription_info(), which sets nrepl_origins, is still only > called for old clusters >= 17 in check_new_cluster(): > > if (GET_MAJOR_VERSION(old_cluster.major_version) >= 1700) > ... > get_subscription_info(&old_cluster); > > and check_new_cluster_replication_origins() returns early on it: > > if (old_cluster.nrepl_origins == 0) > return; > > For a < 17 old cluster get_subscription_info() is never called, so > nrepl_origins stays 0 and this returns early. So when such a cluster has a > (user-created) origin, the origin still gets dumped and recreated, while > the "new cluster must have no origins" and max_active_replication_origins > checks are skipped, and the upgrade fails during restore instead of at the > check step. nrepl_origins is just a count(*) on pg_replication_origin, so > moving its collection out of the >= 1700 block should be enough. > > 2) 004_subscription.pl only checks subscription origins (pg_). Since > the patch migrates all origins, should we also create a user origin > (pg_replication_origin_create()) and verify its roident/remote_lsn after > the upgrade? That would also cover the case in (1). > > Thanks, > Rui > --00000000000075c9480654c5ee0e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Ajin,

Thanks for v8. A c= ouple of comments:

1) The PG17 gating seems inconsistent between the= dump and the check now.
dumpReplicationOrigins() is called unconditiona= lly:

=C2=A0 =C2=A0 if (binary_upgrade && archDumpFormat =3D= =3D archNull)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 dumpReplicationOrigins(conn);<= br>
but get_subscription_info(), which sets nrepl_origins, is still only=
called for old clusters >=3D 17 in check_new_cluster():

=C2= =A0 =C2=A0 if (GET_MAJOR_VERSION(old_cluster.major_version) >=3D 1700)=C2=A0 =C2=A0 =C2=A0 =C2=A0 ...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 get_subscr= iption_info(&old_cluster);

and check_new_cluster_replication_ori= gins() returns early on it:

=C2=A0 =C2=A0 if (old_cluster.nrepl_orig= ins =3D=3D 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;

For a < 17 o= ld cluster get_subscription_info() is never called, so
nrepl_origins sta= ys 0 and this returns early. So when such a cluster has a
(user-created)= origin, the origin still gets dumped and recreated, while
the "new= cluster must have no origins" and max_active_replication_origins
c= hecks are skipped, and the upgrade fails during restore instead of at thecheck step. nrepl_origins is just a count(*) on pg_replication_origin, so=
moving its collection out of the >=3D 1700 block should be enough.
2) 004_subscription.pl onl= y checks subscription origins (pg_<oid>). Since
the patch migrates= all origins, should we also create a user origin
(pg_replication_origin= _create()) and verify its roident/remote_lsn after
the upgrade? That wou= ld also cover the case in (1).

Thanks,
Rui
--00000000000075c9480654c5ee0e--