[PATCH] Avoid a REPACK worker startup hang

From: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
To: pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>
Cc: Antonin Houska <ah(at)cybertec(dot)at>, alvherre(at)kurilemu(dot)de, mihailnikalayeu(at)gmail(dot)com
Subject: [PATCH] Avoid a REPACK worker startup hang
Date: 2026-09-13 09:20:45
Message-ID: CAM527d9A7FBXJn7A3w2VAPq0Gojm7tnUDFMh1uwJitGfi2kNeQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

On REL_19_STABLE at 6bc236c8, my automated (AI) harness reproduced a
worker startup failure 3/3 times in each of two clusters. Start a
disposable postmaster with a low RLIMIT_NPROC, open the leader connection,
exceed that limit with same-UID helper processes, then run
`repack (concurrently) t`.

The postmaster logs `could not fork background worker process: Resource
temporarily unavailable`. No worker starts, and the leader remains in
IPC/RepackWorkerExport until an external statement_timeout; without one it
has no internal exit. The condition-variable wait consumes the latch wake
reporting the worker-state change.

The attached patch waits directly on the latch, checks the worker handle,
reports an initialization error if it stopped, and preserves queued errors.
The injection test covers failure before DSM attachment and after queue
attachment, unchanged storage, and same-backend retry.

Assertions/injection-points build: 14/14 isolation, 4/4 injection
regression, 240/240 core regression.

I haven't spent much time reviewing this manually: I'm testing several PG19
areas in parallel. The harness tested this thoroughly, but I'd appreciate a
look from people who worked on this. If it doesn't make sense, please let
me know; I'll exclude it from scope.

Attached: 0001-repack-worker-startup.patch

Nik

Attachment Content-Type Size
0001-repack-worker-startup.patch application/octet-stream 12.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-09-13 09:57:18 Re: Implement waiting for wal lsn replay: reloaded
Previous Message Nikolay Samokhvalov 2026-09-13 08:20:01 Re: PG19: two RI fast-path issues found while testing the batching revert