Re: Anti-wraparound autovacuum stops for good after no slot available for new autovacuum worker process

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-01 00:34:41
Message-ID: CALdYYtSGtW-UtVLkznmnD6zJnB8xMCRNFi0HYZO97FBDSESagw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> wrote:

> So I think the av_launcherpid change is only needed in the 18, if we
decide to
> backpatch.

Yeah, makes sense. Thanks for testing on 19 - I'm seeing that here too.
With 53 databases past the limit, REL_19_STABLE + v3 finished within 2s
(default 16 slots & autovacuum_worker_slots = 1). REL_18_STABLE + v3 took
52s, vs under 2s with the av_launcherpid change (16 slots & 1 slot). I've
attached a REL_18_STABLE v3 patch with that change as a .txt so cfbot skips
it.

> The loop inside do_start_emergency_worker() should also handle
> ConfigReloadPending. If autovacuum was turned on, we can give the
> WorkerInfo back with cancel_starting_worker() and hand off the work
> to the normal launcher at that point.

Good call, updated this in v3. If a reload turns autovacuum on, it calls
cancel_starting_worker() to release WorkerInfo and returns to let the
normal launcher handle it. I also moved the "took too long to start"
WARNING into the two callers (after releasing AutovacuumLock in
do_start_emergency_worker()) and fixed the comment to "has not started".

I actually ran into an edge case testing this handoff. With a 5s
pg_usleep() at the end of FreeWorkerInfo(), I turned autovacuum on during a
failed start. Originally I resent the start request as soon as the reload
signal cut the 1s pause short, before handing off. That request failed too,
and its failure report reached the normal launcher, which kept resending
starts nobody was waiting for (6 extra "no slot available" lines + an
"autovacuum worker started without a worker entry" warning). In v3 it waits
for the top-of-loop checks before asking again. Also updated the main loop
to check that a worker is still starting before resending. All 3 runs with
that fix came back clean (normal launcher took over, no extra "no slot
available" lines, no "without a worker entry" or "took too long" warnings,
all databases vacuumed).

> Min(autovacuum_naptime, 60) * 1000 is now computed in both the main loop
> and do_start_emergency_worker(). Maybe define it once, something like
> AUTOVAC_WORKER_START_TIMEOUT, so the two paths don't drift apart.

✅

> Can you create a commitfest entry for this?

Added it here: https://commitfest.postgresql.org/patch/7763/

I've attached v3 (based on e6671a7489). On an assert-enabled HEAD with
pg_usleep(100000L) at the end of FreeWorkerInfo(), unpatched HEAD stalled
in 2 of 2 runs, and v3 finished 4 of 4 (retrying all 58 failed starts).
make check passes and pgindent is clean.

Colin

Attachment Content-Type Size
v3-REL_18-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch.txt text/plain 10.2 KB
v3-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch application/octet-stream 9.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-12-01 00:38:43 Re: BUG #19947: Rules see parent generated expression instead of routed partition's expression
Previous Message Ishjaap Singh 2026-12-01 00:30:15 Re: BUG #19936: Planning is slower on 19.0 with many partial indexes on a SQL function