From 5cdbe18a3bc793ea97162a944d44cafd6dc2abea Mon Sep 17 00:00:00 2001 From: ChangAo Chen Date: Sat, 27 Jun 2026 15:44:53 +0800 Subject: [PATCH v6] Do not check permissions in get_all_vacuum_rels. When doing a database-wide vacuum, we scan pg_class to build a list of vacuumable relations without locking them. The permissions check might report an error if a concurrent drop happens because of failing to search the syscache. This commit remove the permissions check in get_all_vacuum_rels and the permissions check will happen later when we process each relation. This also makes the behavior consistent across database-wide vacuum, vacuum and autovacuum. --- src/backend/commands/vacuum.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index a4abb29cf64..7d364f3bc21 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -723,6 +723,7 @@ vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple, char *relname; Assert((options & (VACOPT_VACUUM | VACOPT_ANALYZE)) != 0); + Assert(CheckRelationOidLockedByMe(relid, AccessShareLock, true)); /*---------- * A role has privileges to vacuum or analyze the relation if any of the @@ -1068,10 +1069,6 @@ get_all_vacuum_rels(MemoryContext vac_context, int options) !isTempOrTempToastNamespace(classForm->relnamespace)) continue; - /* check permissions of relation */ - if (!vacuum_is_permitted_for_relation(relid, classForm, options)) - continue; - /* * Build VacuumRelation(s) specifying the table OIDs to be processed. * We omit a RangeVar since it wouldn't be appropriate to complain -- 2.54.0