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

From: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
To: Colin McDonnell <colinmcd94(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-30 17:18:22
Message-ID: CAN12+Y+s9HknemmP9jRfdSj2d2cV=vxBLuOzx_n+Hvy5vf3nWw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks for v2!

> 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.

I tested this with 53 databases past the limit, the default 16 slots
and autovacuum = off.

REL_18_STABLE, unpatched: 0.87s
REL_18_STABLE + v2: 52.2s
REL_18_STABLE + v2 + av_launcherpid change: 0.87s
REL_19_STABLE, unpatched: 0.87s
REL_19_STABLE + v2: 0.93s

So you are right about 18, but I don't see this on 19. It's true that the
worker can't signal the emergency launcher on 19 either, since
av_launcherpid is still set after the emergency branch. But since
d9c3c943653, the postmaster wakes the launcher when a worker exits, so
the emergency launcher does not sit in the 1s timeout. That commit is in
19 and HEAD, but not 18.

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

I have a few more comments on v2.

1/

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.

Also, move the "took too long to start" WARNING out of
cancel_starting_worker() and into its 2 current callers. This way we
don't emit it when the work is handed off to the normal launcher. In
do_start_emergency_worker(), emit it after releasing AutovacuumLock.

Also, cancel_starting_worker() should say the worker "has not started"
rather than "never started", since the worker may still start after we
hand off to the normal launcher.

2/

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.

What do you think?

Can you create a commitfest entry for this?

Sami

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-11-30 17:32:28 BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax
Previous Message Dmitry Dolgov 2026-11-30 17:06:40 Re: BUG #19957: jsonpath `last` returns the wrong index after a filter containing `exists($x[0])`