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

From: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
To: Pavan <prampalli30(at)gmail(dot)com>
Cc: 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-12-06 04:41:52
Message-ID: CAPHduZDDo4rEuXd9CZ19DGS17PMwzHjFerz9YkVR+1Neew4Gog@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Dec 5, 2026 at 6:32 PM Pavan <prampalli30(at)gmail(dot)com> wrote:
> Instead of moving CacheInvalidateHeapTuple() in typecmds.c, the patch
> in CF #7743 moves GetCurrentCommandId(true) from
> RegisterRelcacheInvalidation() into PrepareInvalidationState() [...]
> perhaps both make sense together, or a committer
> can weigh in on the preferred approach.

Hi Pavan,

Thanks for the cross-link. I tested both patches on master (91d71a71cb,
cassert): each alone and both together.

All the repros from #19790 and #19919 fail on master and pass with
either patch and with both: SAVEPOINT then CREATE TABLE / DROP DOMAIN /
DROP TABLE / ADD CONSTRAINT, the PL/pgSQL EXCEPTION case, IF EXISTS on
a missing constraint, a NOT NULL constraint, a SELECT in between, and
the single DO block. The regression test from each patch fails on
master and passes with the other patch too. A plan prepared in another
backend still sees the dropped constraint after commit with both.

With your patch, regress, isolation and test_decoding (regress +
isolation) pass. Both patches together apply cleanly and pass regress
and isolation.

On parallel mode: I added a temporary LOG in PrepareInvalidationState()
when IsInParallelMode() and ran the regress schedule with
debug_parallel_query = regress, plus parallel VACUUM, parallel index
builds, and PARALLEL SAFE functions doing DDL/ANALYZE from a parallel
query. It never fired; the DDL is rejected earlier with "cannot execute
... during a parallel operation". So I found no case where your change
hits the "cannot modify data in a parallel worker" check.

On master, the only transactional invalidation queued with no catalog
write in the same command seems to be the one in
AlterDomainDropConstraint(). The other ALTER DOMAIN forms, ALTER
PUBLICATION RENAME and ANALYZE in a transaction don't trigger the error.

I'd prefer your change as the fix, since it covers future callers too.
The part of mine still worth keeping is not queuing the invalidation
when nothing was dropped; that can go on top. Only one of the two
tests is needed.

Regards,
Sai Pranav

On Sun, Dec 6, 2026 at 12:09 AM Pavan <prampalli30(at)gmail(dot)com> wrote:
>
> Sorry for the broken link in my previous email, here is the
> working link to BUG #19919 / CF #7743:
>
> [1] https://postgr.es/m/19919-c286b9e822bf23b9@postgresql.org
> [2] https://commitfest.postgresql.org/patch/7743/
>
> Regards,
> Pavan

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ishjaap Singh 2026-12-06 12:36:49 Re: BUG #19975: ALTER SUBSCRIPTION ... SET (slot_name, failover) updates the old slot
Previous Message Manu 2026-12-06 04:26:50 Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result