Re: [PATCH] Preserve replication origin OIDs in pg_upgrade

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Rui Zhao <zhaorui126(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade
Date: 2026-11-03 04:25:33
Message-ID: CAFPTHDYCdy+GXTOO8ApS9oXOFWXsh8uxbB4j+P_3wNp3A7DBZA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 30, 2026 at 8:16 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Hi,

> Proposed fix
> =======
> Origins for tablesync workers can exist only while the synchronization is on-going,
> so my idea is does not allow upgrading during the synchronization. For now,
> the check function check_old_cluster_subscription_state() ensures all sync are done,
> but it's called when the source is PG17+, which supports migrating the pg_subscription_rel.
> I think we can do for the same all cases.
>
> Note
> ====
> check_old_cluster_subscription_state() also ensures that all subscriptions have
> the respective replication origins. For now upgrading PG16- node can be done
> even if subscriptions do not have origins, but such a case would be additionally
> rejected after the fix.
> I felt it's harmless because there are no benefits for origin-missing subscriptions,
> but please post here if you have any doubts.
>
> How do you feel?
>

Hi Kuroda-san,

+1. I’ve done this in the attached v22:
check_old_cluster_subscription_state() now runs for all supported old
cluster versions, not only 17 and later.

I tested an upgrade from a PG10 subscriber to HEAD. pg_upgrade now
rejects both a relation in ‘d’ state and a subscription with a missing
origin. A clean upgrade preserves all origin IDs and remote_lsn
values. I also agree that rejecting origin-less subscriptions is
harmless, so the fallback in CreateSubscription() that created a
missing origin is removed, since it can no longer be reached.

Regards,
Ajin Cherian
Fujitsu Australia

Attachment Content-Type Size
v22-0001-Preserve-subscription-OIDs-during-pg_upgrade.patch application/octet-stream 10.2 KB
v22-0002-Preserve-replication-origin-IDs-during-pg_upgrad.patch application/octet-stream 46.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message solai v 2026-11-03 04:55:54 Re: Incorrect selectivity estimates for NOT on nullable boolean columns
Previous Message Hayato Kuroda (Fujitsu) 2026-11-03 04:20:03 RE: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation