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: 0001-Force-timeouts-off-in-the-REPACK-CONCURRENTLY-decodi.patch
Description: Binary data

Attachment: N1-repro.log
Description: Binary data

Reply via email to