From 288c7c88cb3f163bd642e3768d9c34eabe22a43b Mon Sep 17 00:00:00 2001 From: Shihao Zhong Date: Sat, 5 Sep 2026 17:07:19 -0400 Subject: [PATCH] Force timeouts off in the REPACK (CONCURRENTLY) decoding worker The worker connects as the table owner in a new session, so a role- or database-level lock_timeout applies to it and cancels its wait for older transactions, and the user running REPACK cannot override it. Turn the settable timeouts off in the worker, as autovacuum does. --- src/backend/commands/repack_worker.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c index af7e2a94764..bbb45454494 100644 --- a/src/backend/commands/repack_worker.c +++ b/src/backend/commands/repack_worker.c @@ -26,6 +26,7 @@ #include "storage/ipc.h" #include "storage/proc.h" #include "tcop/tcopprot.h" +#include "utils/guc.h" #include "utils/memutils.h" #define PGREPACK_PLUGIN "pgrepack" @@ -105,6 +106,20 @@ RepackWorkerMain(Datum main_arg) BackgroundWorkerInitializeConnectionByOid(shared->dbid, shared->roleid, BGWORKER_BYPASS_ROLELOGINCHECK); + /* + * Force settable timeouts off, like autovacuum does. We run in a new + * session as the table owner, so role- and database-level settings + * apply here even though the user running REPACK cannot see or override + * them. A lock_timeout would otherwise abort the wait for older + * transactions in the snapshot builder, and a transaction_timeout would + * abort the whole command. + */ + SetConfigOption("statement_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE); + SetConfigOption("transaction_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE); + SetConfigOption("lock_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE); + SetConfigOption("idle_in_transaction_session_timeout", "0", + PGC_SUSET, PGC_S_OVERRIDE); + /* * Transaction is needed to open relation, and it also provides us with a * resource owner. -- 2.37.1 (Apple Git-137.1)