public inbox for [email protected]  
help / color / mirror / Atom feed
From: shveta malik <[email protected]>
To: Ajin Cherian <[email protected]>
Cc: Zsolt Parragi <[email protected]>
Cc: [email protected]
Cc: shveta malik <[email protected]>
Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade
Date: Mon, 6 Jul 2026 10:42:24 +0530
Message-ID: <CAJpy0uDaboZmDV3DPKNo4bxfgsS1Bps96OmsypmDC1189YZhuw@mail.gmail.com> (raw)
In-Reply-To: <CAFPTHDYfDHQeQshXi7GDOQz3N8YdY6SNSmpoSAbnaQPBkVfv6A@mail.gmail.com>
References: <CAFPTHDa5aP8ixTZBygGAe48E1N=DvuPzcXikw7bNKixLMN3pVg@mail.gmail.com>
	<OS9PR01MB12149E188221BED862E4BE9E0F5342@OS9PR01MB12149.jpnprd01.prod.outlook.com>
	<CALDaNm2-uwpbJ8fnrssp+hORvOutsqRoZAsa05xVVzXe5Bt3bw@mail.gmail.com>
	<CAFPTHDaNLRqPAda1RUDVfSDH7eLTaONv0UEmc9H5sdMW1Li2Bg@mail.gmail.com>
	<CAN4CZFOb3urMsLPsEyVrYR7-7yA+BC5kDgQQd0nAQ8xj2zyRcA@mail.gmail.com>
	<CAFPTHDYqpuZ6o2-HuCJDYqJ7GY3+zV+Xo-gT7PAgi4Bkz+oTxw@mail.gmail.com>
	<CAN4CZFN4oLdxLwUXHUPV-5mFmK+4dcnppP00fV3i4qmMYCAkGA@mail.gmail.com>
	<CAFPTHDbBiTfjYkQwYTNA2a4LRp8Sp7_zB59fmV0R7977ztxgmg@mail.gmail.com>
	<CAFPTHDaftSwzGTGbFEw8rwDBsub0XqcDm1wxQcquj-Y3PC2qrg@mail.gmail.com>
	<CANhcyEVercsNbgC5CTkMNzh_w_Jv1uK7RQg9vEvAeNQhoBHCKQ@mail.gmail.com>
	<CAJpy0uAXynzWr4w_9GkJC3i=LL9WsRCZYVWAV0PgKmgs8riWzg@mail.gmail.com>
	<CAFPTHDavPyxsWjK0cRO3yOaP4u8FGYrOJuXJB-4wzneAY3H3Ug@mail.gmail.com>
	<CANhcyEVFSutXXdt_0XMCD37NE7Yd7ROdDVEE06D8YVyPNEBFHg@mail.gmail.com>
	<CANhcyEVd7eDKGtsrUqwZO5McTG4dsJ+X8OxO31Xgu6sWmo--hw@mail.gmail.com>
	<CAFPTHDbyVt_ggdi+rOP4=jBmgU=DDgYWuLxc4oQ6ux-T0H-ZBg@mail.gmail.com>
	<CAHWVJhGoi+2bzZDNxtnB8Xc+DuFKB=YvqC0Xoc_HfzcgHAwMUg@mail.gmail.com>
	<CAFPTHDbWKQjv4QfHaNiXosZ1TD0ZHc2hFyFFNB2RvLsJeJoH6g@mail.gmail.com>
	<CAN4CZFPdFHwnew+wxt4UcXyjMYc3aXeR0XsR6_wZ=LEMGWEJFQ@mail.gmail.com>
	<CAFPTHDYfDHQeQshXi7GDOQz3N8YdY6SNSmpoSAbnaQPBkVfv6A@mail.gmail.com>

On Wed, Jul 1, 2026 at 8:20 AM Ajin Cherian <[email protected]> wrote:
>
> All the above changes are updated in patch v10.
>

Thanks for the patch. I have not reviewed completely yet, but please
find comments so far:


1)
+ * In binary-upgrade mode, skip origin creation here. This is required to
+ * preserve the roident from the old cluster for this subscription's origin.

Shall we slightly tweak it to:
/*
 * In binary-upgrade mode, skip origin creation here. It will be
 * created separately so that the origin ID (roident) from the
 * old cluster can be preserved for this subscription.
 */

dumpReplicationOrigins:
2)
+ appendPQExpBufferStr(buf,
+ "SELECT o.*, os.remote_lsn "

It will be better to be more specific here to make it more future proof:
SELECT o.roident, o.roname, os.remote_lsn

3)
+ if (PQntuples(res) > 0)
+ fprintf(OPF, "--\n-- Replication Origins \n--\n\n");
+
+ for (int i = 0; i < PQntuples(res); i++)

Instead of fetching it in loop, we can fetch it once and use it:
ntups = PQntuples(res)

4)
+ appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve
replication origin roident and remote_lsn\n");

Seeing the pattern of other such comments in file, we can change
'origin' to be more specific 'pg_replication_origin'

5)
get_replication_origin_info:
+ res = executeQueryOrDie(conn, "SELECT count(*) AS norigins "
+    "FROM pg_catalog.pg_replication_origin");

I don't see alias 'norigins' being sued anywhere. We can get rid of it
if not needed.

6)
get_subscription_info: I think a bug is introduced with the new change.

Earlier query was below which will always return a row even if there
is no subscription entry:

postgres=# SELECT count(*) AS nsub,
       'f' AS retain_dead_tuples
FROM pg_catalog.pg_subscription;
 nsub | retain_dead_tuples
------+--------------------
    0 | f

Now, this will not even return a result if there are no subscription entries:

postgres=# SELECT 'f' AS retain_dead_tuples
FROM pg_catalog.pg_subscription;
 retain_dead_tuples
--------------------
(0 rows)

So this line of code will access a non existing result:

  i_retain_dead_tuples = PQfnumber(res, "retain_dead_tuples");


Should we simply do:
res = executeQueryOrDie(conn,
"SELECT false AS retain_dead_tuples");
(false/'f' anything is fine)

instead of:
res = executeQueryOrDie(conn,
"SELECT 'f' AS retain_dead_tuples "
"FROM pg_catalog.pg_subscription");

thanks
Shveta






view thread (45+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade
  In-Reply-To: <CAJpy0uDaboZmDV3DPKNo4bxfgsS1Bps96OmsypmDC1189YZhuw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox