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-03 21:32:02
Message-ID: CALdYYtQAJwKPVCZrti33gF7AdWWqMmGpS6ixfJsdSMgOQvQ9Cg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Sami,

Appreciate the review!

> Let's leave that a separate patch.

Yeah works for me 👍

> I thought about adding some tests with injection points, not sure if
> it's worth it though.

I'm happy to write a test if you think it's worth the extra code, totally
up to you. I haven't tried it yet, but the idea would be an injection point
at the end of FreeWorkerInfo(), holding the finished worker's child slot
the way pg_usleep() did in my testing. A test in src/test/modules/test_misc
next to 006_signal_autovacuum.pl (which already uses
autovacuum-worker-start) could run with autovacuum = off and
autovacuum_worker_slots = 1. It would consume about 131k XIDs to get past
autovacuum_freeze_max_age = 100000, wait for "no slot available" in the
logs, wake the point, and check all databases get vacuumed.

> A nit on the 18 patch. The av_launcherpid assignment now sits between the
> emergency mode comment and the if:
> ...
> Maybe move it before the comment and explain why it's needed.

Moved the assignment up ahead of the emergency-mode comment in the
REL_18_STABLE patch, with a comment explaining why. An emergency launcher
waits for a worker to start, then that worker wakes it using av_launcherpid
- if that's unset, starting a worker waits for the latch timeout. The
emergency branch clears av_launcherpid before exiting, matching
AutoVacLauncherShutdown() for a normal launcher.

Checked on an assert-enabled REL_18_STABLE build - make check passes and
pgindent leaves it unchanged. 53 databases past the limit vacuumed in 1.1s
and 1.3s with the default 16 slots, and 1.3s and 1.3s with
autovacuum_worker_slots = 1.

Here are the v5 patches:
- v5-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch (master,
identical to v4 apart from the version tag)
-
v5-REL_18-0001-Retry-a-failed-worker-start-in-the-emergency-auto.patch.txt
(REL_18_STABLE, with the moved assignment)

Colin

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2026-12-03 21:50:13 Re: BUG #19942: SIGSEGV crash (and wrong results) in MERGE ... RETURNING WITH (OLD/NEW) with VIRTUAL generated colum
Previous Message Sami Imseih 2026-12-03 20:48:11 Re: Anti-wraparound autovacuum stops for good after no slot available for new autovacuum worker process