pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix crash decoding a change to a partition pending detach. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9a849767eb281c9502aab4a7384a654004ec6ffe 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1b72026d4143b55511d7fc15508819d3d750aa62 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 | 20 ++++++++---- 4 files changed, 74 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1fd94839ea873d01fa43dbc99328acd0c91e92b5 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 | 20 ++++++++---- 4 files changed, 74 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0a6393254e14a7cd1882e00518be1c6c264231f4 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 | 20 ++++++++---- 4 files changed, 74 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix crash decoding a change to a partition pending detach. @ 2026-11-12 05:58 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Amit Kapila @ 2026-11-12 05:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.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_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/38fb2e3e5e2e65b8ecd09e36d0c522da4d5d8362 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 | 20 ++++++++---- 4 files changed, 74 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2026-11-12 05:58 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org> 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org> 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org> 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org> 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org> 2026-11-12 05:58 pgsql: Fix crash decoding a change to a partition pending detach. Amit Kapila <akapila@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox