public inbox for [email protected]  
help / color / mirror / Atom feed
From: Gurmokh <[email protected]>
To: wenhui qiu <[email protected]>
Cc: David Rowley <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: New vacuum config to avoid anti wraparound vacuums
Date: Tue, 28 Apr 2026 21:21:35 +0000
Message-ID: <8udBo1vgTX5lWBFmq4HKWGy94FOomFWWc_xr4Hc7jJ91NzZbdvWB_QqfVDF1jmSk-Eavuuu-y3aUZOJZPubVdUcpLHTNmf-0zDuMkzBArug=@protonmail.com> (raw)
In-Reply-To: <CAGjGUAL3J5nfz4+xgOGMB1Os6MHK_B24-YSc6YF3HWGcHWQonA@mail.gmail.com>
References: <CeFiI3W4yXPznxyELYARQ5H6Cfy1HJIm0Tsn5CDVINyORFVwKfIMwc5EKHYlVzAjy5vgHgfA7X7lgfA3CnD0GchBvuanglpr4xd-IoyjPWY=@protonmail.com>
	<CAApHDvonBh3YPGzFjg79-9RPRcnWVrzZyLR1xr05WxdY=EqjSg@mail.gmail.com>
	<AkM6NiLDE4pBr-PL1M79iydoh3enMO-UruUI2Xd3n3xOysAjGbm-lYz34DrLZcKbtRehBYM8lHRY6zVYZZkqL8vcM55LEt8i0lKVGwWUX54=@protonmail.com>
	<CAApHDvoa0ZwBjFYRypxHaqdFYwwDd6rTr5GWY8LASXr3kWY8Dg@mail.gmail.com>
	<GLEV5fUtSc1YTeNMMmCbl3RsUJXzbclrg4tgYP_xh1db3F8ErUZ-lmLaVDNPBS0JeanYUCVKyanNRY-rEbo2Ep1XnDEQuJB8DuuwtqdFGdA=@protonmail.com>
	<CAGjGUAL3J5nfz4+xgOGMB1Os6MHK_B24-YSc6YF3HWGcHWQonA@mail.gmail.com>

On Friday, April 24th, 2026 at 8:39 AM, wenhui qiu <[email protected]> wrote:

> HI Mok
>
> On Fri, Apr 24, 2026 at 2:16 PM Mok <[email protected]> wrote:
>
>> On Thursday, April 23rd, 2026 at 3:10 PM, David Rowley <[email protected]> wrote:
>>
>>> On Fri, 24 Apr 2026 at 01:04, Mok <[email protected]> wrote:
>>> >
>>> > On Thursday, April 23rd, 2026 at 4:44 AM, David Rowley <[email protected]> wrote:
>>> >
>>> > > On Thu, 23 Apr 2026 at 08:19, Mok <[email protected]> wrote:
>>> > > > For example, set to 0.8 a 'standard' vacuum would be triggered when the table reached 160million with a default 200million setting.
>>> > >
>>> > > If that's what you want, why wouldn't you set the
>>> > > autovacuum_freeze_max_age to 160million?
>>> >
>>> > Because that would trigger a 'to-prevent-wraparound' vacuum, which is what this change is trying to avoid.
>>>
>>> Yes, it would. Why do you want to prevent them? I believe a few people
>>> have been alarmed in the past about the "to prevent wraparound" text
>>> in pg_stat_activity or when they saw those words in the logs. The
>>> default 200 million autovacuum_freeze_max_age setting triggers an
>>> autovacuum when it's less than 10% of the way into exhausting the
>>> transaction space for the table. What you're proposing with an
>>> autovacuum_age_scale_factor of 0.1 sounds like it would result in an
>>> auto-vacuum when only 1% of the transaction ID space is consumed! I
>>> think you're under the false impression that these anti-wraparound
>>> vacuums are bad. They're not.
>>>
>>> There's some documentation that might be worthwhile reading in [1].
>>>
>>> David
>>>
>>> [1] https://www.postgresql.org/docs/18/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
>>>
>>
>>> On large tables they can be quite inconvenient so avoiding them is preferable. My example of 0.1 is to test the patch if you tried it. The range for this
>>> setting is 0.1 -> 1 with the latter effectively rendering the setting moot.
>> I don't know where you got that idea from. For example have a table with 1 billion records, autovacuum_vacuum_scale_factor = 0.01 ,
>> 50+1000000000 *0.01 = 10000050 ,you can reduce autovacuum_vacuum_max_threshold  substantially lower than 10000050 ,
>> vacthresh= (float4) vac_base_thresh + vac_scale_factor * reltuples;
>> if (vac_max_thresh>=0&&vacthresh> (float4) vac_max_thresh)
>> vacthresh= (float4) vac_max_thresh;
>>
>> There's no fundamental difference between this and your parameter

I think I may not have explained my reasoning correctly, I'll try again. I am suggesting another configuration parameter that can be used to trigger autovacuums.

The config parameters in [1] autovacuum_vacuum_threshold, autovacuum_vacuum_insert_threshold, autovacuum_vacuum_scale_factor, autovacuum_vacuum_insert_scale_factor and autovacuum_vacuum_max_threshold rely on regular activity to trigger autovacuums. However it is entirely plausible that these can be configured with values that are not sensitive enough and a table breaches the autovacuum_freeze_max_age triggering an aggressive vacuum to prevent wraparound before any less aggressive vacuums can be triggered.

In my experience I have seen tables that have significant activity and still not meet the criteria to trigger an autovacuum and subsequently age out. I have seen production systems slow to a grind waiting for these to complete.

What I'm suggesting here is to have a configurable parameter that represents a value as a percentage of autovacuum_freeze_max_age that would enable a table to be autovacuumed before a vacuum to prevent wraparound is triggered if none of the above conditions are met.

For example. In my patch setting the autovacuum_age_scale_factor to 0.99 would mean a table is autovacuumed when 99% of the autovacuum_freeze_max_age age is reached. In the event that none of the above conditions are met there is a 'failsafe' condition that will trigger a standard vacuum over a wraparound one.

The value I mentioned in my original email was to effectively test the patch without having to wait for the tx count to reach the required number.

The allowed values in my patch range from 0.1 to 1. Both ends being extreme examples. 0.1 likely being too small and you should be relying scale factor and thresholds. 1 effectively setting the value to be the same as the actual autovacuum_freeze_max_age and likely clashing with the same conditions that would trigger a wraparound vacuum. This setting would represent a failsafe of sorts and a sensible value would be somewhere in the range close to 1.

[1] https://www.postgresql.org/docs/18/runtime-config-vacuum.html

Gurmokh

>>

view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: New vacuum config to avoid anti wraparound vacuums
  In-Reply-To: <8udBo1vgTX5lWBFmq4HKWGy94FOomFWWc_xr4Hc7jJ91NzZbdvWB_QqfVDF1jmSk-Eavuuu-y3aUZOJZPubVdUcpLHTNmf-0zDuMkzBArug=@protonmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox