Re: Fix ALTER DOMAIN VALIDATE CONSTRAINT locking
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>, Peter Eisentraut <peter@eisentraut.org>,
jian he <jian.universality@gmail.com>
Date: 2026-06-12T11:47:28Z
Lists: pgsql-hackers
On Mon, Jun 8, 2026 at 12:54 PM Chao Li <li.evan.chao@gmail.com> wrote:
> See the attached patch for details. I also added an isolation test that follows the repro above.
Thanks for the patch! It looks good to me.
I just have a few minor review comments.
* The lockmode is used for relations using the domain. It should be
* ShareLock when adding a new constraint to domain. It can be
* ShareUpdateExclusiveLock when validating an existing constraint.
This comment in validateDomainCheckConstraint() still references
ShareUpdateExclusiveLock, so it seems to need updating.
Regarding the test, I think it would be safer to also check whether
pg_constraint.convalidated is set correctly. For example:
-----------------------
step s3_validate { ALTER DOMAIN alter_domain_validate_d VALIDATE
CONSTRAINT alter_domain_validate_d_pos; }
+step s3_validated { SELECT convalidated FROM pg_constraint WHERE
conname = 'alter_domain_validate_d_pos'; }
step s3_check { SELECT count(*) FROM alter_domain_validate_t; }
-permutation s1_lock s2_insert s3_add s3_validate s1_unlock s3_check
+permutation s1_lock s2_insert s3_add s3_validate s1_unlock s3_validated s3_chec
-----------------------
After the fix is committed, we should probably also ask Bruce to update
the following v19 release note item?:
Reduce lock level of ALTER DOMAIN ... VALIDATE CONSTRAINT to match
ALTER TABLE ... VALIDATE CONSTRAINT (Jian He) §
Regards,
--
Fujii Masao
Commits
-
Fix ALTER DOMAIN VALIDATE CONSTRAINT locking
- 64797ad97d6e 19 (unreleased) landed