Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Antonin Houska <ah(at)cybertec(dot)at>
Subject: Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables
Date: 2026-03-25 09:05:22
Message-ID: 039cca2d-5574-4dad-92e6-6e72c1747b23@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v2-0001-Skip-other-sessions-temp-tables-in-REPACK-CLUSTER.patch text/x-patch 3.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2026-03-25 09:06:22 Re: [PATCH] Add prepared_orphaned_transaction_timeout GUC
Previous Message Antonin Houska 2026-03-25 09:00:49 Re: Adding REPACK [concurrently]