RE: [PATCH] Preserve replication origin OIDs in pg_upgrade

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Ajin Cherian' <itsajin(at)gmail(dot)com>
Cc: 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>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Subject: RE: [PATCH] Preserve replication origin OIDs in pg_upgrade
Date: 2026-10-15 05:26:04
Message-ID: OS7PR01MB18317CFD00457D42BDBE4B841F59C2@OS7PR01MB18317.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ajin,

> Thanks for your comments, I agree with all your comments and have
> addressed them in v19.

Thanks for updating the patch. I requested my LLM to review your patch set,
It found a possible issue, when the source is PG16-.. Do you think it should
be fixed?

If the source node is PG16-, the apply worker can start even during the pg_upgrade
command. So, it may be possible that the replication origin can be go backward with
the below steps:

1. the pg_dumpall command reads the remote_lsn from the old source. the value is
LSN_1.
2. the apply worker on the old source receives and applies changes.
3. the worker also updates the replication origin. The value is LSN_2.
4. then the source is stopped and heap is copied by the pg_upgrade command.
The data is replicated till LSN_2, but the remote_lsn would be LSN_1.
5. the apply worker requests replicating data from LSN_1.

It's not problematic if the confirmed_flush has already been updated to LSN_2 on
publisher side, the publisher ignores the requested startpoint (LSN_1) and starts
for LSN_2. remote_lsn can be eventually corrected.
If not replicated yet, the publisher may send the same data thus can cause the
data duplication error. But IIUC it seems possible even for HEAD. The apply worker
does not request the specific startpoint (i.e., 0/0), and the walsender replicates
after the confirmed_flush.

To the end, the outcome is mostly the same, but origin may show the wrong value
for a while.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-10-15 06:00:00 Re: [PATCH v2] Fix races in Windows pthread emulation
Previous Message Tom Lane 2026-10-15 05:24:52 Re: Bug in logical decoding with DDL and subtransactions