From 56da12f8f5d4c6b1deee60aa209722ccc57a18b1 Mon Sep 17 00:00:00 2001 From: ChangAo Chen Date: Sat, 27 Jun 2026 15:44:53 +0800 Subject: [PATCH v5] 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 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index a4abb29cf64..d5ff7dcdb11 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -715,6 +715,8 @@ vacuum(List *relations, const VacuumParams *params, BufferAccessStrategy bstrate * If not, issue a WARNING log message and return false to let the caller * decide what to do with this relation. This routine is used to decide if a * relation can be processed for VACUUM or ANALYZE. + * + * Note: the relation must be locked to prevent a concurrent drop. */ bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple, @@ -1068,10 +1070,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