1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Fix lock release for role membership grants in DROP OWNED BY.

Commit 6566133c5f added a case for AuthMemRelationId in
AcquireDeletionLock(), but not ReleaseDeletionLock(). The fall-through
case would go to UnlockDatabaseObject(), which would raise a WARNING;
and the lock would be retained until the end of the transaction.

Add the missing branch.

Discussion: https://postgr.es/m/2487ddcd737d4fc8e408e87aa9ad4365eed3bbb3.camel@j-davis.com
Backpatch-through: 16
This commit is contained in:
Jeff Davis
2026-08-03 12:21:05 -07:00
parent 9a8c933837
commit a0daa0b412
4 changed files with 42 additions and 0 deletions

View File

@@ -1529,6 +1529,9 @@ ReleaseDeletionLock(const ObjectAddress *object)
{
if (object->classId == RelationRelationId)
UnlockRelationOid(object->objectId, AccessExclusiveLock);
else if (object->classId == AuthMemRelationId)
UnlockSharedObject(object->classId, object->objectId, 0,
AccessExclusiveLock);
else
/* assume we should lock the whole object not a sub-object */
UnlockDatabaseObject(object->classId, object->objectId, 0,

View File

@@ -0,0 +1,8 @@
Parsed test spec with 2 sessions
starting permutation: s1b s1d s2d s1c
step s1b: BEGIN;
step s1d: DROP OWNED BY regress_dropowned_grantor;
step s2d: DROP OWNED BY regress_dropowned_grantor; <waiting ...>
step s1c: COMMIT;
step s2d: <... completed>

View File

@@ -119,3 +119,4 @@ test: matview-write-skew
test: lock-nowait
test: ddl-dependency-locking
test: pub-concurrent-drop
test: drop-owned-grant

View File

@@ -0,0 +1,30 @@
# Test locking of role membership grants during concurrent DROP OWNED BY.
setup
{
CREATE ROLE regress_dropowned_role;
CREATE ROLE regress_dropowned_member;
CREATE ROLE regress_dropowned_grantor;
GRANT regress_dropowned_role TO regress_dropowned_grantor
WITH ADMIN OPTION;
SET ROLE regress_dropowned_grantor;
GRANT regress_dropowned_role TO regress_dropowned_member;
RESET ROLE;
}
teardown
{
DROP ROLE regress_dropowned_member;
DROP ROLE regress_dropowned_grantor;
DROP ROLE regress_dropowned_role;
}
session s1
step s1b { BEGIN; }
step s1d { DROP OWNED BY regress_dropowned_grantor; }
step s1c { COMMIT; }
session s2
step s2d { DROP OWNED BY regress_dropowned_grantor; }
permutation s1b s1d s2d s1c