Fix pg_upgrade to detect invalid logical replication slots on PG19
Lakshmi N <lakshmin.jhs@gmail.com>
From: Lakshmi N <lakshmin.jhs@gmail.com>
To: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-20T08:57:43Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-pg_upgrade-to-detect-invalid-logical-replication.patch (application/octet-stream) patch 0001
Hi Hackers, The PG19-optimized slot catchup query uses a CTE that filters on invalidation_reason IS NULL, then cross-joins it with the main slot query. When ALL logical slots in a database are invalid, the CTE returns zero rows, and the cross join produces an empty result set. This causes pg_upgrade to silently skip those slots entirely -- neither detecting them as invalid (which should block the upgrade) nor attempting to migrate them. The pre-PG19 query path does not have this problem because it queries pg_replication_slots directly without a cross join. This may not impact upgrade to PG19 but will change the behavior for PG20 upgrade. Fix by changing the cross join to a LEFT JOIN, so that invalid slots still appear in the result set with NULL caught_up values. Regards, Lakshmi
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_upgrade: Fix detection of invalid logical replication slots.
- e471dc591219 19 (unreleased) landed