[PATCH] Fix autovacuum freeze bug where weight can lower a table's freeze score

Started by shihao zhong3 months ago3 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
2 days ago

@global #bug

#bug
Jump to latest
#1shihao zhong
zhong950419@gmail.com

Hi hackers,

In the autovacuum freeze scores added by d7965d65fc5, raising a freeze
weight can make a table's score smaller instead of larger. When a table
gets old, its score is raised to a power to grow fast, but a larger weight
makes this start while the score is still below one, where a power makes it
smaller. So a bigger weight can push a table near wraparound down the list.
The safety net still works; only the order changes.

The attached patch raises the score to a power only when that makes it
bigger, with a test. New in v19, so no backport needed.

Thanks,
Shihao

Attachments:

t253626_1
0001-Don-t-let-a-larger-autovacuum-freeze-weight-lower-th.patchapplication/octet-stream; name=0001-Don-t-let-a-larger-autovacuum-freeze-weight-lower-th.patchDownload+94-3
#2Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: shihao zhong (#1)
Re: [PATCH] Fix autovacuum freeze bug where weight can lower a table's freeze score

Hi,

On Mon, Aug 31, 2026 at 8:57 PM shihao zhong <zhong950419@gmail.com> wrote:

Hi hackers,

In the autovacuum freeze scores added by d7965d65fc5, raising a freeze
weight can make a table's score smaller instead of larger. When a table
gets old, its score is raised to a power to grow fast, but a larger weight
makes this start while the score is still below one, where a power makes it
smaller. So a bigger weight can push a table near wraparound down the list.
The safety net still works; only the order changes.

The attached patch raises the score to a power only when that makes it
bigger, with a test. New in v19, so no backport needed.

Thanks for reporting this. This is already being discussed here:
/messages/by-id/apWcbq91BAfhmsKU@nathan. The
TAP test case looks interesting and will definitely be useful. You may
want to propose it in that thread or here.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

#3shihao zhong
zhong950419@gmail.com
In reply to: Bharath Rupireddy (#2)
Re: [PATCH] Fix autovacuum freeze bug where weight can lower a table's freeze score

Thanks for reporting this. This is already being discussed here:
/messages/by-id/apWcbq91BAfhmsKU@nathan. The
TAP test case looks interesting and will definitely be useful. You may
want to propose it in that thread or here.

Hi Bharath,

Thanks for pointing that out, I had rebased my patch based on Nathan's patch
and responded in that thread.

Thanks,
Shihao