REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout
Date: 2026-09-06 22:05:40
Message-ID: CAGRkXqTYaBjFvjtjPb1+=sZWvt93=2c472bmM+xdG7w9ZvAydA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI hackers,

Running two REPACK (CONCURRENTLY) on one database with
ALTER DATABASE ... SET lock_timeout = '5s', the second one fails:

ERROR: canceling statement due to lock timeout
CONTEXT: waiting for ShareLock on transaction 2076
REPACK decoding worker

The worker waits for the first REPACK's XID in the snapshot builder.
It runs in its own session as the table owner, so the database-level
lock_timeout applies to it, and SET lock_timeout = 0 in the REPACK
session does not reach it.

The attached patch turns the settable timeouts off in the worker, as
autovacuum does. statement_timeout and cancel on the REPACK session
still stop the whole command.

Separately, the wait itself means REPACK (CONCURRENTLY) runs are
serialized. A PROC_IN_SAFE_IC-like flag could let the worker skip
other REPACK transactions; I can look into that if there is interest.

Thanks,
Shihao

Attachment Content-Type Size
0001-Force-timeouts-off-in-the-REPACK-CONCURRENTLY-decodi.patch application/octet-stream 2.0 KB
N1-repro.log application/octet-stream 4.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-09-06 23:47:33 Re: Rename of varatt_external to varatt_external_oid
Previous Message Alexander Lakhin 2026-09-06 21:00:00 Re: Internal error codes triggered by regression tests and user queries, take 2