Add autovacuum_warning to surface concurrent vacuum collisions
Add autovacuum_warning to surface concurrent vacuum collisions
Hi hackers, I would like to propose a patch that adds a new GUC, autovacuum_warning (off by default), which logs a message when an autovacuum worker tries to process a table that is already being vacuumed by another worker. Motivation: The goal is to give DBAs an early signal that autovacuum is no longer keeping up, while there is still time to tune the configuration and avoid the worst outcomes (severe bloat, transaction ID wraparound). Today, by the time the existing wraparound warnings or anti-wraparound vacuums appear, the system is already in trouble; there is no earlier hint that autovacuum is becoming saturated. This is modeled after checkpoint_warning, which logs when checkpoints are happening too frequently so that DBAs know to raise max_wal_size. In the same spirit, autovacuum_warning gives DBAs an early, actionable signal that autovacuum is struggling, so they can react and tune the relevant parameters promptly. Design: When autovacuum_warning is enabled and a worker skips a table because another worker is already vacuuming it, the following is written to the server log: LOG: autovacuum: table "public.foo" is already being vacuumed by another worker HINT: Consider tuning the autovacuum configuration parameters. The hint is intentionally generic: a collision has no single root cause, and pointing at one specific parameter could be misleading. Like checkpoint_warning, the message is emitted at LOG level and the feature is off by default, so it adds nothing for users who don't opt in. The patch is attached. Thoughts? -- Best regards, Shinya Kato NTT OSS Center
Re: Add autovacuum_warning to surface concurrent vacuum collisions
От:
Hüseyin Demir <huseyin.d3r@gmail.com>
Дата:
Hi, It is an area that genuinely lacks some observability however, I have some concerns about this patch that I think we can review. The condition being logged is correct, intentional behavior. The skip mechanism is designed exactly for this case: Worker B backs off, moves to the next table, and the system makes progress. Logging correct behavior as if it were a warning conflates a healthy scheduler decision with a fault condition. On any busy OLTP system with autovacuum_max_workers > 1, workers will skip tables held by other workers in every vacuum cycle. That is not a transient edge case and it is the steady state of a loaded database. This means the GUC has two operating modes: on a quiet system it never fires (no value), and on a busy system it always fires (pure noise). The checkpoint_warning analogy does not hold up. checkpoint_warning fires when the system deviates from healthy behavior (checkpoints too frequent). This GUC fires during an expected behavior. Furthermore, checkpoint_warning is an integer (seconds) with built-in rate limiting via elapsed time comparison; a bare boolean offers none of that, so on a loaded system it would emit one log line per skipped table per vacuum cycle per worker. If the goal is to detect genuine autovacuum saturation, I think an example case would be a. worker that completes an entire vacuum cycle having done no work at all because every candidate table was already held by another worker. That condition is already tracked, fires once per wasted cycle rather than once per table, and is a strong signal that a worker slot was completely wasted. That is worth a single LOG Also when it comes to name of GUC shouldn't we follow the log_autovacuum_* pattern ? Regards, Demir.
Re: Add autovacuum_warning to surface concurrent vacuum collisions
От:
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Дата:
Hi, On Mon, Jun 1, 2026 at 5:34 AM Shinya Kato wrote: > > The goal is to give DBAs an early signal that autovacuum is no longer > keeping up, while there is still time to tune the configuration and > avoid the worst outcomes (severe bloat, transaction ID wraparound). > Today, by the time the existing wraparound warnings or anti-wraparound > vacuums appear, the system is already in trouble; there is no earlier > hint that autovacuum is becoming saturated. > > Design: > > When autovacuum_warning is enabled and a worker skips a table because > another worker is already vacuuming it, the following is written to > the server log: > > LOG: autovacuum: table "public.foo" is already being vacuumed by > another worker > HINT: Consider tuning the autovacuum configuration parameters. > > The hint is intentionally generic: a collision has no single root > cause, and pointing at one specific parameter could be misleading. Right, but unlike the checkpointer message which says exactly what to do "increase max_wal_size", this hint leaves one with nothing specific to tune or take care of. Without the relevant parameters and their current values, it's hard to make anything meaningful out of it. Can we avoid adding a GUC just for this? If we agree it's worth emitting this information, after clarifying what exactly to tune when this situation is hit, then maybe we could just add it to pg_stat_all_tables instead - something like autovacuum_concurrent_skip_count, similar to autovacuum_count and its friends - and explain nicely in the docs what to look for when this counter starts growing for a table. -- Bharath Rupireddy Amazon Web Services: https://aws.amazon.com
Re: Add autovacuum_warning to surface concurrent vacuum collisions
От:
Shinya Kato <shinya11.kato@gmail.com>
Дата:
On Sat, Jun 27, 2026 at 3:53 PM Bharath Rupireddy wrote: > Can we avoid adding a GUC just for this? If we agree it's worth > emitting this information, after clarifying what exactly to tune when > this situation is hit, then maybe we could just add it to > pg_stat_all_tables instead - something like > autovacuum_concurrent_skip_count, similar to autovacuum_count and its > friends - and explain nicely in the docs what to look for when this > counter starts growing for a table. I like this better than the GUC. A growing per-table counter is something a DBA can watch over time and reason about. So I would like to drop the GUC and pursue a per-table counter instead. That surface is already being built in the "Track skipped tables during autovacuum and autoanalyze" thread [1], which adds skipped-vacuum and skipped-analyze counters to pg_stat_all_tables for tables skipped when a lock cannot be acquired. I raised the concurrent-worker skip there [2] as another skip reason worth tracking on the same surface. It needs its own discussion, so I plan to take it up in that thread or start a new one, rather than here. [1] https://www.postgresql.org/message-id/20260324151133.7940a5c1f2ebd594d54da481%40sraoss.co.jp [2] https://www.postgresql.org/message-id/CAOzEurSn7YDLLNnZW6etRJ167ZG4hvdaYDxeX5qwy%2BtuOFe4Dw%40mail.gmail.com -- Best regards, Shinya Kato NTT OSS Center
Re: Add autovacuum_warning to surface concurrent vacuum collisions
От:
Shinya Kato <shinya11.kato@gmail.com>
Дата:
On Tue, Aug 18, 2026 at 12:00 AM Bharath Rupireddy wrote: > Thanks. I came across the CF entry for this > https://commitfest.postgresql.org/patch/6830/. Since you plan to > discuss this in [1] which already has a CF entry, can we close this > one? Yeah, I've withdrawn it now. Thanks for letting me know. -- Shinya Kato NTT OSS Center