pgsql: Skip other sessions' temp tables in REPACK, CLUSTER, and VACUUM

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Skip other sessions' temp tables in REPACK, CLUSTER, and VACUUM
Date: 2026-05-05 14:23:31
Message-ID: E1wKGgN-000SzW-2A@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Skip other sessions' temp tables in REPACK, CLUSTER, and VACUUM FULL

get_tables_to_repack() and get_all_vacuum_rels() were including other
sessions' temporary tables in their output work list, causing REPACK,
CLUSTER and VACUUM FULL (when executed without a table list) to attempt
to acquire AccessExclusiveLock on them, potentially blocking for an
extended time. Fix by skipping other-session temp tables early, before
they are added to the list.

This issue is ancient, but there have been no complaints about it that I
know of, so I'm opting for not backpatching at present.

Author: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Discussion: https://postgr.es/m/0b555318-2bf2-46df-9377-09629a2a59db@uni-muenster.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a0a0c0c20ec5f8787bb1be5f476c4e59f6810634

Modified Files
--------------
src/backend/commands/repack.c | 25 ++++++++++++++++++++++++-
src/backend/commands/vacuum.c | 5 +++++
2 files changed, 29 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-05-06 08:53:03 pgsql: Document deprecated --wal-directory option for pg_verifybackup
Previous Message John Naylor 2026-05-05 11:53:13 pgsql: Add missing guard for __builtin_constant_p