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-11-20 17:46:40
Message-ID: CALdYYtSpd9q4QVq3BzSaJcoyB_orhZsgwpS13_S=pyNXCB_pOg@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:
> Since a78af04270 a configuration setting is enough to hit it, while
> before 18 a start has to really fail, and we haven't seen that
> reported. So I'd fix this in HEAD and backpatch to 18.

Totally agree.

> HEAD already handles it since 842169b6c11, so I'd leave 18 and 19 as
> is. It's separate from this fix. WDYT?

I think it stops being separate once the launcher waits, though. On 18 and
19 nothing wakes the emergency launcher when its worker starts, so with the
patch each database waits for the 1s latch timeout, whatever
autovacuum_worker_slots is. On REL_18_STABLE (813a74bc5a) with the default
16 slots, 53 databases past the limit took 2s without the patch and 52s
with it. Setting av_launcherpid before the emergency branch, and back to 0
before that launcher exits, brought it to 1s. So I'd add that to the 18 and
19 backpatch.

> If the wait loop errors out, the launcher comes back here, takes a
> second WorkerInfo and loses the first.

Yep, the error recovery block falls through to the emergency branch again.
v2 waits on a WorkerInfo that's already reserved instead of taking another,
and clears the failed-start flag when none is.

> Also, this could also be one function, say do_start_emergency_worker(),
> placed next to do_start_worker().

For sure, done 👍 The emergency branch calls it where it called
do_start_worker().

> I'd only ask again if the worker hasn't shown up during the pause. And
> the continue skips the interrupt handling, so I'd move it to the top of
> the loop.

Yep, both done.

> Nit, this is the WorkerInfo, not the worker. Maybe "reserved"?

✅

> The helper looks good. Maybe Assert that the lock is held?

✅

v2 attached, against d27418375d. It applies to REL_18_STABLE and
REL_19_STABLE too. On an assert-enabled build of HEAD with
pg_usleep(100000L) at the end of FreeWorkerInfo(), HEAD stalled in 2 of 2
runs, and v2 vacuumed every database in 4 of 4, retrying all 58 failed
starts. make check passes and pgindent leaves it unchanged.

Colin

Attachment Content-Type Size
v2-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch application/octet-stream 6.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-11-20 17:52:54 Re: BUG #19923: SEARCH/CYCLE with DISTINCT in the recursive term: rows depend on input order
Previous Message Tom Lane 2026-11-20 17:42:26 Re: BUG #19923: SEARCH/CYCLE with DISTINCT in the recursive term: rows depend on input order