Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables
Jim Jones <jim.jones@uni-muenster.de>
From: Jim Jones <jim.jones@uni-muenster.de>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Antonin Houska <ah@cybertec.at>
Date: 2026-03-25T09:05:22Z
Lists: pgsql-hackers
Attachments
- v2-0001-Skip-other-sessions-temp-tables-in-REPACK-CLUSTER.patch (text/x-patch) patch v2-0001
Hi Chao,
Thanks for the thorough review.
On 25/03/2026 02:55, Chao Li wrote:
> It uses isTempOrTempToastNamespace(relation->rd_rel->relnamespace) to decide relation->rd_islocaltemp.
>
> So, I think this patch should also use "!isTempOrTempToastNamespace(classForm->relnamespace)" instead of isOtherTempNamespace(class->relnamespace). I tried that locally, and it works for me.
I agree. In get_all_vacuum_rels() and the pg_class scan branch of
get_tables_to_repack(), relpersistence == RELPERSISTENCE_TEMP already
establishes the relation is a temp table, so
!isTempOrTempToastNamespace() alone is sufficient to identify
other-session temp tables.
In the usingindex path of get_tables_to_repack(), Form_pg_class is not
available, so there is no relpersistence to use as a pre-filter. The
explicit isAnyTempNamespace() check is required to avoid incorrectly
skipping permanent tables. This is pretty much what
isOtherTempNamespace() does internally -- the only change is inlining it
to avoid the obsolete wrapper.
* Skip temp relations belonging to other sessions */
{
Oid nsp = get_rel_namespace(index->indrelid);
if (!isTempOrTempToastNamespace(nsp) && isAnyTempNamespace(nsp))
{
UnlockRelationOid(index->indrelid, AccessShareLock);
continue;
}
}
v2 attached.
Thanks!
Best, Jim
Commits
-
Skip other sessions' temp tables in REPACK, CLUSTER, and VACUUM FULL
- a0a0c0c20ec5 19 (unreleased) landed