Crashes on a partition whose concurrent detach never finished

From: Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, ashutosh(dot)bapat(dot)oss(at)gmail(dot)com
Subject: Crashes on a partition whose concurrent detach never finished
Date: 2026-08-15 15:24:13
Message-ID: CADzfLwWoFPT+a73=A=bsNWRMZQ98NpBEMgE=t1FS4O4_=QVLfA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, everyone! (Added CC to authors of patches that introduced the
issues described below, sorry if it is duplicate for you).

I was working on stress-suite and discovered a few crashes caused
mainly by the same issue.

DETACH PARTITION ... CONCURRENTLY marks the partition and commits, and
only then waits. If that wait is interrupted the mark remains.
Only PARTITION ... FINALIZE clears it. Reaching this needs no race,
and the state outlives the command that made it.

In that state pg_class still says relispartition, while
get_partition_ancestors() already reports nothing.

Three places read the former as meaning the latter is not empty and
ask for its last element, which causes an assert() or NPE:

- get_rel_sync_entry()
- getIdentitySequence()
- RelationBuildPublicationDesc()

The last one is a v19 regression, so I think it may be added to the
open items list.

Patches are attached, one for each place; each includes a test that
reproduces the crash.

Best regards,
Mikhail.

Attachment Content-Type Size
v1-0001-Fix-crash-decoding-a-change-to-a-partition-pendin.patch application/x-patch 7.1 KB
v1-0002-Fix-crash-inserting-into-a-partition-pending-deta.patch application/x-patch 6.7 KB
v1-0003-Fix-crash-on-UPDATE-or-DELETE-of-a-partition-pend.patch application/x-patch 5.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-08-15 16:26:14 GIN VACUUM can corrupt internal posting tree pages
Previous Message Xuneng Zhou 2026-08-15 15:11:07 Re: Implement waiting for wal lsn replay: reloaded