Disallow concurrent ALTER DOMAIN and DROP DOMAIN

Started by jian heover 1 year ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrybuild failedCI history

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t51622_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t51622_1 && git checkout t51622_1

Patchset v1 (message #1) is on t51622_1

Jump to latest
#1jian he
jian.universality@gmail.com

hi

similar to thread "Prevent internal error at concurrent CREATE OR
REPLACE FUNCTION"
[1]: /messages/by-id/20250331200057.00a62760966a821d484ea904@sraoss.co.jp

We should prevent concurrent modifications to a domain's definition. Currently,
it is possible for one session to drop a domain while another session
simultaneously adds a constraint to it.
It may result in errors such as "tuple concurrently updated."

also dropping a domain should not be allowed if another session is
modifying it, IMHO.

The attached patch is very similar to the "CREATE OR REPLACE FUNCTION"
thread [1]/messages/by-id/20250331200057.00a62760966a821d484ea904@sraoss.co.jp,
by acquiring a AccessExclusiveLock on the changed domain oid.
Other sessions must wait for the current transactions to finish
modifying the domain definition
before making changes on it.

[1]: /messages/by-id/20250331200057.00a62760966a821d484ea904@sraoss.co.jp

Attachments:

t51622_1
v1-0001-fix-concurrent-issue-in-ALTER-DOMAIN.patchtext/x-patch; charset=US-ASCII; name=v1-0001-fix-concurrent-issue-in-ALTER-DOMAIN.patchDownload+126-1
#2Andres Freund
andres@anarazel.de
In reply to: jian he (#1)
Re: Disallow concurrent ALTER DOMAIN and DROP DOMAIN

Hi,

On 2025-05-23 21:19:07 +0800, jian he wrote:

similar to thread "Prevent internal error at concurrent CREATE OR
REPLACE FUNCTION"
[1].

We should prevent concurrent modifications to a domain's definition. Currently,
it is possible for one session to drop a domain while another session
simultaneously adds a constraint to it.
It may result in errors such as "tuple concurrently updated."

also dropping a domain should not be allowed if another session is
modifying it, IMHO.

The attached patch is very similar to the "CREATE OR REPLACE FUNCTION"
thread [1],
by acquiring a AccessExclusiveLock on the changed domain oid.
Other sessions must wait for the current transactions to finish
modifying the domain definition
before making changes on it.

I don't know if this is still an active patch - if it is, it'd be good to fix
CI:
https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F5773
it doesn't build.

If it's not current anymore, please close the CI entry.

Greetings,

Andres