| From: | Colin McDonnell <colinmcd94(at)gmail(dot)com> |
|---|---|
| To: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Anti-wraparound autovacuum stops for good after no slot available for new autovacuum worker process |
| Date: | 2026-12-02 21:14:58 |
| Message-ID: | CALdYYtR2Jp9n3BiRBJw=uG4jg0n6YiSAfwFL5ZHSFCLm8RrCSg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi Sami,
Thanks for looking at v3.
> On timeout, do_start_emergency_worker() gives the WorkerInfo back and
> returns without starting a worker.
> ...
> The main loop doesn't stop there, it goes on to start another worker.
> I think we should do the same
> ...
> The header comment of do_start_emergency_worker() should also
> mention that a worker that doesn't start in time is replaced,
> not just given back.
Yeah good catch - changed v4 to release the WorkerInfo, log the WARNING,
clear AutoVacForkFailed, and call do_start_worker() instead of returning. I
also updated the header comment to match your wording.
Tested the timeout path with autovacuum_worker_slots = 1,
autovacuum_naptime = 1s (1s start timeout), and pg_usleep(5000000L) at the
end of FreeWorkerInfo() to hold the child slot for 5s, on initdb's three
databases. v3 stopped at the first timeout and waited for the next 65536
XIDs (2 of 2 runs). v4 kept replacing the timed-out start about 1s apart,
then vacuumed all three databases as soon as the slot cleared (2 of 2 runs,
8 replaced starts per run).
> In the main loop, I find the new comment hard to follow.
> ...
> Maybe keep the original paragraph as is and explain the new check in
> its own paragraph,
Much clearer. I kept the original paragraph and added your paragraph
underneath it.
> I know I suggested "reserved" earlier, but how about "starting_worker"
> everywhere, to match av_startingWorker? In do_start_emergency_worker()
> it can be one WorkerInfo used both at the top and in the loop.
Sounds good - renamed to starting_worker everywhere, using a single
WorkerInfo across the top check and loop in do_start_emergency_worker().
> /* with nothing starting, a report of a failed start is stale */
✅
I also timed 18 vs 19 across 53 databases past the limit (chain time from
server log timestamps, 16 slots).
REL_18_STABLE - unpatched 1.6s and 1.7s, v4 52.5s and 52.5s, v4 with the
av_launcherpid change 3.0s and 3.3s (1.3s and 1.4s with
autovacuum_worker_slots = 1).
REL_19_STABLE (3 runs each) - unpatched 3.0 to 7.5s, v4 1.3 to 3.3s.
So yeah, the av_launcherpid change belongs on 18.
Tested v4 with an assert-enabled build of HEAD (74f5aba377) and
pg_usleep(100000L) at the end of FreeWorkerInfo(). Unpatched HEAD stalled
in 2 of 2 runs on initdb's three databases. v4 vacuumed all 53 databases in
3 of 3 runs, retrying all 157 failed starts. Turning autovacuum on during a
failed start handed over cleanly in 3 of 3 runs. make check passes and
pgindent leaves it unchanged.
Separate thing I noticed during testing - in 1 of 6 runs on HEAD with
autovacuum_worker_slots = 1 and 53 databases, wraparound vacuuming paused
for 27s. A launcher started 7 ms after the previous worker logged the new
wrap limit, saw that worker holding the single WorkerInfo, and exited
without starting a new worker. Looks like the race from the 2024
xid_wraparound thread [1] - it resumes at the next 65536 XIDs and
reproduces without this patch too. Do you think the emergency launcher
should wait for that worker to exit and retry as well, either here or in a
separate patch?
Attached v4-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch
(master, 74f5aba377) and
v4-REL_18-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch.txt
(REL_18_STABLE, with the av_launcherpid change).
[1]
https://www.postgresql.org/message-id/5811175c-1a31-4869-032f-7af5e3e4506a@gmail.com
Colin
| Attachment | Content-Type | Size |
|---|---|---|
| v4-REL_18-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch.txt | text/plain | 10.7 KB |
| v4-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch | application/octet-stream | 10.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Jeff Davis | 2026-12-02 19:59:19 | Re: Regex fails to capture group consisting of empty string in non-greedy case |