pgsql: Validate publisher for retain_dead_tuples in the apply worker.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Validate publisher for retain_dead_tuples in the apply worker.
Date: 2026-08-04 03:35:16
Message-ID: E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Validate publisher for retain_dead_tuples in the apply worker.

Enabling retain_dead_tuples requires the publisher to run PostgreSQL 19 or
later and to not be in recovery. Previously this was checked only at DDL
time. That forced ALTER SUBSCRIPTION ... ENABLE to connect to the
publisher, so pg_upgrade (which re-enables subscriptions during restore)
failed if the publisher was unreachable. It was also not authoritative,
since the publisher's version or recovery status can change afterwards,
for example after a failover.

Perform the check authoritatively in the apply worker when it connects,
and stop doing it when enabling a subscription. ENABLE is the only command
issued during restore that triggered it, so this also fixes the pg_upgrade
failure. The DDL-time check is kept as a convenience for the other paths,
none of which are issued during restore.

Reported-by: Noah Misch <noah(at)leadboat(dot)com>
Analyzed-by: Jeff Davis <pgsql(at)j-davis(dot)com>
Author: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Jeff Davis <pgsql(at)j-davis(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Backpatch-through: 19, where it was introduced
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch@microsoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a3fed7608f75336ba748ab2784b2c5fa8cbf284d

Modified Files
--------------
src/backend/commands/subscriptioncmds.c | 22 +++++++++-------------
src/backend/replication/logical/worker.c | 15 +++++++++++++++
src/include/commands/subscriptioncmds.h | 4 ++++
3 files changed, 28 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-08-04 04:09:11 pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig
Previous Message David Rowley 2026-08-04 01:30:10 pgsql: Remove unused field from PartitionDescData struct