Re: BUG #19790: "cannot start a subtransaction ... inval messages" after "ALTER DOMAIN ... DROP CONSTRAINT"

From: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
To: alpkeles99(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19790: "cannot start a subtransaction ... inval messages" after "ALTER DOMAIN ... DROP CONSTRAINT"
Date: 2026-11-21 07:28:14
Message-ID: CAPHduZCbAvqw3J6yMYL5qkaZiHaM592+16RW+ZkD70V7mP82fA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I reproduced this on master (4a26e36f87). BUG #19919 is the same problem:
https://postgr.es/m/19919-c286b9e822bf23b9@postgresql.org

AlterDomainDropConstraint() queues an invalidation for the domain's pg_type
row after the constraint is deleted. The deletion's
CommandCounterIncrement() has already run, and the one at the end of the
command does nothing because no catalog change follows it, so the message
stays pending until the next subtransaction start trips over it. DROP
CONSTRAINT IF EXISTS on a missing constraint hits it too.

The attached patch queues the invalidation before the deletion, so the
deletion's CommandCounterIncrement() processes it, and only when a
constraint is actually dropped. Plans that depend on the constraint are
still rebuilt. The test in domain.sql fails without the fix and passes with
it; regress and pg_upgrade pass.

v1 is for master. The REL_18 version is the same change (it cherry-picks
cleanly), tested the same way on REL_18_STABLE.

Regards,
Sai Pranav

Attachment Content-Type Size
REL_18-v1-0001-Fix-unprocessed-inval-messages-error-after-ALTER-.patch application/octet-stream 4.5 KB
v1-0001-Fix-unprocessed-inval-messages-error-after-ALTER-.patch application/octet-stream 4.5 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Raja Sai pranav 2026-11-21 08:27:21 Re: BUG #19917: nbtree skip scan leaks one copy of a pass-by-reference skip array element per rescan
Previous Message Raja Sai pranav 2026-11-21 07:14:19 Re: BUG #19881: CLUSTER uses a disabled sort path when enable_sort is off