Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

Поиск
Список
Период
Сортировка
Искать

Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
Álvaro Herrera <alvherre@kurilemu.de>
Дата:
On 2026-Sep-12, shihao zhong wrote:

> 1. The comment in RepackWorkerMain() now says why only lock_timeout and
> transaction_timeout are passed.  lock_timeout is armed by any lock wait,
> and transaction_timeout by StartTransaction().  Both can fire in the
> worker: the wait for older transactions in the snapshot builder is a
> lock wait, and the worker's transaction spans the whole command.
> statement_timeout and idle_in_transaction_session_timeout are only
> armed by the command loop in PostgresMain(), which a background worker
> never runs.  I hope that answers Chao's question without touching
> autovacuum.

Thanks.  I pushed the patch, but didn't keep the detailed comment.  I
don't think we need to explain the details of how these timeouts work in
this comment, and it may be easy for the comment to become outdated.

I added the word "relevant" to the comment, to try and satisfy Chao's
concern: a reader of this code trying to add a new worker will have to
figure out what does "relevant" mean in whatever case they're trying to
implement :-)

> 2. A lock_timeout on the table owner role does not reach the worker,
> and one set in the REPACK session does.  It fails on unpatched master
> and passes with 0001.

Did you mean to reference the proposed new test in this paragraph?  I
think so, but the text says something else.  (I don't really know what
the text tries to convey).  Anyway, I didn't push this test either,
because I think it's likely to fail randomly on slow buildfarm machines,
so we would have to adjust the timeouts, and that becomes a whack-a-mole
game that I'm not very interested in playing at this point.

Thanks for the report and fix,

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Before you were born your parents weren't as boring as they are now. They
got that way paying your bills, cleaning up your room and listening to you
tell them how idealistic you are."  -- Charles J. Sykes' advice to teenagers


Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Hi Alvaro,

> Thanks.  I pushed the patch, but didn't keep the detailed comment.

Thanks for pushing it, and for the backpatch to 19.

> Did you mean to reference the proposed new test in this paragraph?

Yes, sorry, that paragraph was about the test in 0002. You are right
that it is timing sensitive. It only caught the bug after I added a
pg_sleep before the COMMIT, so it would be fragile on slow machine.
Leaving it out is fine.

Thanks,
Shihao

Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Вложения:
Hi Alvaro,

I looked at the other settings to see if any of them has the same
problem. I found temp_file_limit, the worker uses it for its decoding
files. 003 fixes it the same way as the timeouts. 

Thanks,
Shihao

Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Hi Alvaro,

A gentle ping on 003. I should have shown the symptom last time. If the
table owner has a role level temp_file_limit, REPACK (CONCURRENTLY) fails
under concurrent updates, even when a superuser runs it:

ERROR:  temporary file size exceeds "temp_file_limit" (64kB)
CONTEXT:  slot "pg_repack_11897", output plugin "pgrepack", in the change callback, associated LSN 0/20A7BF00

That was ALTER ROLE owner SET temp_file_limit = '64kB' and 20k updates
during the REPACK. The caller can't override it, same as the timeouts
before a62ff0829d6. The patch still applies cleanly on master. 

Should we also add that to the open item list?

Thanks,
Shihao

Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
Álvaro Herrera <alvherre@kurilemu.de>
Дата:
Hi,

On 2026-Sep-17, shihao zhong wrote:

> Hi Alvaro,
> 
> I looked at the other settings to see if any of them has the same
> problem. I found temp_file_limit, the worker uses it for its decoding
> files. 003 fixes it the same way as the timeouts.

I have pushed this, thanks.

I am concerned about the GUC variables changing type and the repack code
not noticing.  Suppose temp_files_limit were changed to be int64; we
don't receive a compiler warning for the mismatching type in
repack_internal.h.  I thought about adding a
StaticAssertVariableIsOfType, but I have no idea how to make it compare
not to a type, but to the type of some other variable.  These _Generic()
things are unknown to me.

I don't understand why you were adding #include "fd.h" to repack.c.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Finally, the phrase, 'No one was ever fired for buying an IBM' I don't believe
has ever been translated into German."                       (Leonard Tramiel)
https://www.atarimagazines.com/startv3n1/threeyearsofst.php


Re: REPACK (CONCURRENTLY) decoding worker is canceled by lock_timeout

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Вложения:
Hi Alvaro,

> I have pushed this, thanks.
Thanks for pushing that.

> I am concerned about the GUC variables changing type and the repack code
> not noticing....
I think we can just use type of + StaticAssertVariableIsOfType here, a new patch
is attached about that.

> I don't understand why you were adding #include "fd.h" to repack.c.
ehh, that is auto imported by ide, my mistake. Will recheck all the #include for
future patches.

Thanks,
Shihao
FAQ