Experimental patch for terminating VACUUM freeze blockers

From: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Experimental patch for terminating VACUUM freeze blockers
Date: 2026-05-13 11:56:43
Message-ID: CAGjGUA+vd2XQuePZ5SA2-v8qEyTgoig8Mk+m=doAnPQ2ykySUw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

When a table’s age reaches vacuum_failsafe_age, VACUUM enters failsafe mode
and bypasses nonessential throttling such as autovacuum_vacuum_cost_delay so
it can make progress as aggressively as possible.

However, if VACUUM’s freeze horizon is blocked by an old transaction, the
failsafe behavior alone cannot reduce the table age. In that case, VACUUM
may run at full speed but still be unable to advance relfrozenxid.

I have an experimental patch to explore handling this situation. The patch
adds a GUC, vacuum_freeze_terminate_blockers_pid, which allows VACUUM to
terminate regular client backends whose transaction horizon blocks VACUUM
from advancing its freeze cutoff. The intended targets are
idle-in-transaction sessions and long-running active transactions that are
holding an old xmin or assigned XID.

One possible question is why not rely on idle_in_transaction_session_timeout.
In practice, this parameter is often not configured, and even when it is,
it only addresses idle-in-transaction sessions. It does not help with
active long-running transactions that can also hold back VACUUM’s freeze
horizon.

The patch deliberately does not try to handle other causes of freeze
horizon retention, such as replication slots, hot standby feedback, or
prepared transactions.

This is experimental and intended for discussion.

Attachment Content-Type Size
vacuum_freeze_terminate_blockers_pid.patch application/octet-stream 18.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2026-05-13 12:00:38 Re: Fix REPACK with WITHOUT OVERLAPS replica identity indexes
Previous Message Ashutosh Sharma 2026-05-13 11:55:25 Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication