| From: | Amit Kapila <akapila(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix crash decoding a change to a partition pending detach. |
| Date: | 2026-11-12 05:58:32 |
| Message-ID: | E1xRNpQ-00000000OvE-1cwF@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix crash decoding a change to a partition pending detach.
ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY leaves the partition
marked as detach-pending if its wait is interrupted by a lock timeout, a
cancel, a disconnect. Only DETACH PARTITION ... FINALIZE clears that mark.
In that state pg_class still says relispartition, while
get_partition_ancestors() already reports nothing which
get_rel_sync_entry() was not ready for. It read relispartition as meaning
that the ancestor list is not empty, and asked for its last element, which
is an assertion failure, and a NULL pointer dereference without
assertions. Decoding any change to such a partition for a FOR ALL TABLES
publication gets there, and as the change is never confirmed, a
subscription turns that into a crash loop.
Fetch the ancestors once, up front, and treat a partition with no
ancestors as a standalone table, which is how it is published once the
detach completes.
The crash is reachable since v14 (71f4c8c6f74b) for FOR ALL TABLES
publications with publish_via_partition_root, and since v19
(fd366065e06a) for any FOR ALL TABLES publication.
Author: Mikhail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
Author: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Reviewed-by: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Discussion: https://postgr.es/m/CADzfLwWoFPT%2Ba73%3DA%3DbsNWRMZQ98NpBEMgE%3Dt1FS4O4_%3DQVLfA%40mail.gmail.com
Discussion: https://postgr.es/m/CABdArM64ZSat%3DdB094U8OCBzp1m8_Y85m6T%2BxPEgpLVJb60_rA%40mail.gmail.com
Backpatch-through: 15
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/00e61be2ff8b2cb6ef52794ef61f028ad954d11c
Modified Files
--------------
.../test_decoding/expected/concurrent_ddl_dml.out | 38 ++++++++++++++++++++++
.../test_decoding/specs/concurrent_ddl_dml.spec | 17 ++++++++++
src/backend/catalog/partition.c | 5 +++
src/backend/replication/pgoutput/pgoutput.c | 19 ++++++++---
4 files changed, 74 insertions(+), 5 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-12 06:01:38 | pgsql: Make GetSnapshotData() more resilient on out-of-memory errors |
| Previous Message | shihao zhong | 2026-11-12 04:36:50 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |