| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Ajin Cherian <itsajin(at)gmail(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Subject: | Re: [PATCH] Preserve replication origin OIDs in pg_upgrade |
| Date: | 2026-07-06 05:12:24 |
| Message-ID: | CAJpy0uDaboZmDV3DPKNo4bxfgsS1Bps96OmsypmDC1189YZhuw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Jul 1, 2026 at 8:20 AM Ajin Cherian <itsajin(at)gmail(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Srinath Reddy Sadipiralla | 2026-07-06 05:29:01 | Re: hang during shutdown |
| Previous Message | Bertrand Drouvot | 2026-07-06 05:01:00 | Re: Re-read subscription state after lock in AlterSubscription |