Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables - Mailing list pgsql-hackers

From Jim Jones
Subject Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables
Date
Msg-id 039cca2d-5574-4dad-92e6-6e72c1747b23@uni-muenster.de
Whole thread Raw
In response to Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables
Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables
List 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

pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Andrey Borodin
Date:
Subject: Re: [PATCH] Add prepared_orphaned_transaction_timeout GUC