Re: BUG #19919: Internal Invalidation Error During Savepoint DDL After Dropping a Domain Constraint

From: Pavan <prampalli30(at)gmail(dot)com>
To: nakamurajames123(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19919: Internal Invalidation Error During Savepoint DDL After Dropping a Domain Constraint
Date: 2026-11-24 15:52:12
Message-ID: CAEyqiQHAV2-mYnuDxaXzXvgfkVGMLdqDAUwfiZBgVK0hB+zrAQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

Thanks for the report and clear steps to reproduce the issue.

The issue occurs because AlterDomainDropConstraint() calls
performDeletion() (which runs CommandCounterIncrement() and resets
currentCommandIdUsed to false), and then manually calls
CacheInvalidateHeapTuple() on the domain's pg_type tuple without
modifying pg_type. While RegisterRelcacheInvalidation() calls
GetCurrentCommandId(true) so that CommandCounterIncrement() will flush
queued invalidation messages even without a catalog tuple update,
catcache and other transactional invalidations did not do the same.
As a result, the queued message remained unprocessed in
CurrentCmdInvalidMsgs and tripped PrepareInvalidationState() on the
subsequent DDL inside a savepoint.

The same error also reproduces with
ALTER DOMAIN d DROP CONSTRAINT IF EXISTS nonexistent; followed by
savepoint DDL.

The attached patch moves GetCurrentCommandId(true) from
RegisterRelcacheInvalidation() into PrepareInvalidationState() so that
all transactional invalidation paths mark the command ID as used
(while avoiding unnecessary marking for inplace invalidations), and
adds regression tests in domain.sql.

make check, src/test/isolation, and contrib/test_decoding all pass
with this change.

Regards,
Pavan

Attachment Content-Type Size
v1-0001-Mark-command-ID-used-in-PrepareInvalidationState.patch application/octet-stream 5.4 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Henson Choi 2026-11-24 15:19:03 Re: BUG #19354: JOHAB rejects valid byte sequences