| 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-12-02 17:58:58 |
| Message-ID: | CAN12+YKxkpSTXF_KN89HF8BbYW1Sc5P_+SkkDCwXbrFeWwVKsw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Thanks for v3!
I only looked at v3-0001:
> "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.
This makes sense.
A few more comments:
1/
On timeout, do_start_emergency_worker() gives the WorkerInfo back and
returns without starting a worker.
```
+ ereport(WARNING,
+ errmsg("autovacuum worker took
too long to start; canceled"));
+ return;
```
The main loop doesn't stop there, it goes on to start another worker.
I think we should do the same
here, something like
```
AutoVacuumShmem->av_signal[AutoVacForkFailed] = false;
if (!OidIsValid(do_start_worker()))
return;
ask_again = false;
continue;
```
Otherwise we may lose a round and wait another 65536 XIDs.
The header comment of do_start_emergency_worker() should also
mention that a worker that doesn't start in time is replaced,
not just given back.
maybe:
```
+ * of a worker that doesn't start in time and starts another. An emergency
```
2/
In the main loop, I find the new comment hard to follow.
```
+ * for a little while and resend the
signal, unless no worker
+ * is starting any more: the report
can outlive the start it
+ * was about, as when an emergency
launcher hands over to us.
```
Maybe keep the original paragraph as is and explain the new check in
its own paragraph,
something like:
```
* Only resend the signal if a WorkerInfo is still waiting in
* av_startingWorker. The failed start may be one whose
* WorkerInfo was already given back. Asking again would then
* start a worker that finds no WorkerInfo to claim, so it
* would just log a warning and exit without vacuuming
* anything, while still taking a worker slot that the next
* worker we ask for might need.
```
A few nits:
3/
The value of av_startingWorker goes by "starting", "have_reserved" and
"reserved".
```
+ bool starting;
...
+ bool have_reserved;
...
+ WorkerInfo reserved;
```
I know I suggested "reserved" earlier, but how about "starting_worker"
everywhere, to match av_startingWorker? In do_start_emergency_worker()
it can be one WorkerInfo used both at the top and in the loop.
4/
and then also change:
```
+ /* with nothing reserved, a report of a failed start is stale */
```
```
/* with nothing starting, a report of a failed start is stale */
```
Sami Imseih
Amazon Web Services (AWS)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-12-02 18:03:40 | Re: Regex fails to capture group consisting of empty string in non-greedy case |
| Previous Message | Tom Lane | 2026-12-02 16:58:15 | Re: BUG #19965: btree_gist index on timetz returns too few rows for <, > and <> |