TECHNOLOGY

PostgreSQL avoids VACUUM delay sleeps while holding locks

In this article
THE QUICK TAKE

VACUUM pacing now avoids sleeping while locks are held; qualify delay placement and concurrent effects rather than infer universal speed gains.

PostgreSQL 18.7 changes where VACUUM may honor a requested delay sleep. If locks are held, it does not sleep, and several existing delay calls move to safe points. The correctness question is about where pacing occurs, not simply whether VACUUM is throttled. A maintenance operation that pauses at an unsuitable lock boundary can extend interference with other work even while appearing to reduce its own resource consumption.

Pacing location can matter more than pacing amount

The release does not remove every delay. It skips sleeping under locks and moves calls to safe points. A regression test should therefore observe both lock ownership and the sleep path. Measuring total maintenance runtime alone cannot identify whether a pause occurred at a safe boundary. A shorter VACUUM can still have an undesirable blocking interval, while a longer correctly paced run may interfere less with concurrent work. Those outcomes require different observations.

Concurrent work needs a controlled comparison

A proposed qualification runs representative conflicting operations while triggering VACUUM delay behavior, then records waits alongside maintenance progress. Keep dataset, workload and pacing configuration fixed when comparing versions. The release provides no latency percentile or throughput number, so any local gain must be attributed to that controlled experiment. A general production slowdown can have unrelated causes; the relevant evidence is a delay coinciding with lock ownership at the affected call sites.

A positive pacing case guards against blanket removal

An implementation that never sleeps would avoid this lock-held sleep bug while discarding intended throttling. Include a safe-point case showing that requested pacing still occurs where allowed. The expected invariant is conditional delay placement, not maximum maintenance speed. The patch does not define a universal optimal throttle setting for every storage system. Operators still need the relevant workload and resource budgets when choosing pacing policy, separate from verifying that the implementation obeys its lock boundary.

Keep cleanup correctness separate from scheduling impact

Avoiding unsafe sleeps should preserve the underlying VACUUM work. A qualification should verify expected cleanup completion alongside concurrent wait behavior, rather than declare success from fewer pauses alone. The same release contains index-corruption repairs that need other tests; this pacing fix cannot certify them. Its practical contribution is a clearer separation between holding necessary locks and voluntarily yielding execution, with workload-specific performance conclusions left to measured evidence.

Sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles