nocfbot-0001-Fix-REPACK-to-skip-temporary-tables-of-other-sess.patch
text/x-patch
Filename: nocfbot-0001-Fix-REPACK-to-skip-temporary-tables-of-other-sess.patch
Type: text/x-patch
Part: 0
Message:
Re: Adding REPACK [concurrently]
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0001
Subject: Fix REPACK to skip temporary tables of other sessions
| File | + | − |
|---|---|---|
| src/backend/commands/cluster.c | 15 | 0 |
From be0f2aeeaa53e775d5312be87d0ad34f6cd8c271 Mon Sep 17 00:00:00 2001
From: Jim Jones <jim.jones@uni-muenster.de>
Date: Mon, 23 Mar 2026 16:20:09 +0100
Subject: [PATCH v1] Fix REPACK to skip temporary tables of other sessions
get_tables_to_repack() was adding other sessions' temporary tables
to the work list, causing REPACK to attempt to acquire
AccessExclusiveLock on them. Fix by skipping other-session temp
relations early in get_tables_to_repack(), before they are added
to the list.
---
src/backend/commands/cluster.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 09066db095..f701d426dd 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -1699,6 +1699,13 @@ get_tables_to_repack(RepackCommand cmd, bool usingindex, MemoryContext permcxt)
continue;
}
+ /* Skip temp relations belonging to other sessions */
+ if (isOtherTempNamespace(get_rel_namespace(index->indrelid)))
+ {
+ UnlockRelationOid(index->indrelid, AccessShareLock);
+ continue;
+ }
+
/* noisily skip rels which the user can't process */
if (!repack_is_permitted_for_relation(cmd, index->indrelid,
GetUserId()))
@@ -1753,6 +1760,14 @@ get_tables_to_repack(RepackCommand cmd, bool usingindex, MemoryContext permcxt)
continue;
}
+ /* Skip temp relations belonging to other sessions */
+ if (class->relpersistence == RELPERSISTENCE_TEMP &&
+ isOtherTempNamespace(class->relnamespace))
+ {
+ UnlockRelationOid(class->oid, AccessShareLock);
+ continue;
+ }
+
/* noisily skip rels which the user can't process */
if (!repack_is_permitted_for_relation(cmd, class->oid,
GetUserId()))
--
2.43.0