postgres.git / summary / log / commit / refs
commit e61d44fdee7e299dcbd4e168bda1e6670680aebc
Author: Jeff Davis <jdavis@postgresql.org>
Date: Mon Aug 03 19:21:05 2026 +0000
First released in: 16.15, 17.11, 18.6
Fix lock release for role membership grants in DROP OWNED BY.
Commit 6566133c5f5 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
src/backend/catalog/dependency.c | 3 +++
src/test/isolation/expected/drop-owned-grant.out | 8 +++++++
src/test/isolation/isolation_schedule | 1 +
src/test/isolation/specs/drop-owned-grant.spec | 30 ++++++++++++++++++++++++
4 files changed, 42 insertions(+)
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 494738824cb..9dd4eef6a32 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -1587,6 +1587,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,
diff --git a/src/test/isolation/expected/drop-owned-grant.out b/src/test/isolation/expected/drop-owned-grant.out
new file mode 100644
index 00000000000..ea6cca277b6
--- /dev/null
+++ b/src/test/isolation/expected/drop-owned-grant.out
@@ -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>
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule
index c9c477f1cb2..00e17d7266c 100644
--- a/src/test/isolation/isolation_schedule
+++ b/src/test/isolation/isolation_schedule
@@ -117,3 +117,4 @@ test: serializable-parallel-3
test: matview-write-skew
test: ddl-dependency-locking
test: pub-concurrent-drop
+test: drop-owned-grant
diff --git a/src/test/isolation/specs/drop-owned-grant.spec b/src/test/isolation/specs/drop-owned-grant.spec
new file mode 100644
index 00000000000..636cc213a6b
--- /dev/null
+++ b/src/test/isolation/specs/drop-owned-grant.spec
@@ -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
[parent: d16728b01efc]