| 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-20 17:19:47 |
| Message-ID: | CAN12+Y+fspd9rn_5jwST-=c206cxdqLLogFsyimyFxo-VkRChg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
Thanks for the report.
> With autovacuum = off and autovacuum_worker_slots = 1, the autovacuum that
> the postmaster starts to prevent XID wraparound can stop for good after
> vacuuming one database.
I can reproduce it on HEAD. As I understand it, the old worker still holds
the only child slot until the postmaster cleans up after it, so the new one
can't start. When that happens the emergency launcher has already exited,
so nobody hands its WorkerInfo back and we're stuck.
> A real fork() failure in emergency mode leaks the WorkerInfo the same way
> in older releases, one slot per failure.
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.
> ... there the emergency launcher sets av_launcherpid only after the
> emergency branch ...
HEAD already handles it since 842169b6c11, so I'd leave 18 and 19 as
is. It's separate from this fix. WDYT?
Some comments on the patch.
> + if (!ShutdownRequestPending && OidIsValid(do_start_worker()))
> + wait_for_emergency_worker();
If the wait loop errors out, the launcher comes back here, takes a
second WorkerInfo and loses the first. Unlikely, but easy to avoid by
waiting on a WorkerInfo that's already reserved instead. When none is
reserved, any leftover "failed to start" flag is stale, so clear it
first.
Also, this could also be one function, say do_start_emergency_worker(),
placed next to do_start_worker(). It would start or reuse the worker
and wait for it, and be called where do_start_worker() is now.
WDYT?
> + SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_WORKER);
> + continue;
> + }
.....
.........
> + ResetLatch(MyLatch);
> +
> + if (ShutdownRequestPending)
> + return;
> + if (ProcSignalBarrierPending)
> + ProcessProcSignalBarrier();
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.
> + if (worker == NULL)
Nit, this is the WorkerInfo, not the worker. Maybe "reserved"?
> +cancel_starting_worker(void)
The helper looks good. Maybe Assert that the lock is held?
Sami Imseih
Amazon Web Services (AWS)
| From | Date | Subject | |
|---|---|---|---|
| Next 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 |
| Previous Message | Raja Sai pranav | 2026-11-20 17:12:34 | Re: BUG #19881: CLUSTER uses a disabled sort path when enable_sort is off |