Re: [PATCH] Preserve replication origin OIDs in pg_upgrade

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: Rui Zhao <zhaorui126(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <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-06-24 05:21:20
Message-ID: CAJpy0uCkdF7JtVL_TcbQZkXOZm_-Ez8cxepqTztcAF8zdbUZKw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 24, 2026 at 10:39 AM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
>
> 2)
> replorigin_create_with_id():
>
> + if (SearchSysCacheExists1(REPLORIGNAME, roname_d))
> + ereport(ERROR,
> + errcode(ERRCODE_DUPLICATE_OBJECT),
> + errmsg("replication origin \"%s\" already exists", roname));
>
> Can this ever happen? IIUC, since new-cluster should not have any
> origin (as per the check introduced) and old cluster can not have
> duplicate names, we should not hit this error. Do we want to keep it
> as sanity check? If so, can we put a comment atop it.
>

Analyzed a bit more, with this change in patch002, we see an error change:

Without patch:
postgres=# SELECT pg_replication_origin_create('abcd');
pg_replication_origin_create
------------------------------
1
postgres=# SELECT pg_replication_origin_create('abcd');
ERROR: duplicate key value violates unique constraint
"pg_replication_origin_roname_index"
DETAIL: Key (roname)=(abcd) already exists.

----

With patch:
postgres=# SELECT pg_replication_origin_create('abcd');
pg_replication_origin_create
------------------------------
1

postgres=# SELECT pg_replication_origin_create('abcd');
ERROR: replication origin "abcd" already exists

So without the new check also, we can prevent duplicate name insertion
(even if that happens during upgrade, which I can not see how). The
new error and the check is not wrong, but slightly redundant. Or let
me know if I am missing something.

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-06-24 05:31:12 Re: Add pg_stat_kind_info system view
Previous Message jian he 2026-06-24 05:12:30 Re: Row pattern recognition