agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Validate publisher for retain_dead_tuples in the apply worker.
Date: Tue, 04 Aug 2026 03:35:16 +0000
Message-ID: <E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org> (raw)

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@leadboat.com>
Analyzed-by: Jeff Davis <pgsql@j-davis.com>
Author: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.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(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org>
Permalink:  ../E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Validate publisher for retain_dead_tuples in the apply worker.
  In-Reply-To: <E1wr5vw-000000006Rx-2DQE@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox