Re: [PATCH] Preserve replication origin OIDs in pg_upgrade
shveta malik <shveta.malik@gmail.com>
From: shveta malik <shveta.malik@gmail.com>
To: Ajin Cherian <itsajin@gmail.com>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>,
pgsql-hackers@lists.postgresql.org, shveta malik <shveta.malik@gmail.com>
Date: 2026-07-06T05:12:24Z
Lists: pgsql-hackers
On Wed, Jul 1, 2026 at 8:20 AM Ajin Cherian <itsajin@gmail.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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Introduce replication progress tracking infrastructure.
- 5aa2350426c4 9.5.0 cited