Re: Should vacuum process config file reload more often
Melanie Plageman <melanieplageman@gmail.com>
From: Melanie Plageman <melanieplageman@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Daniel Gustafsson <daniel@yesql.se>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>, Amit Kapila <amit.kapila16@gmail.com>
Date: 2023-03-27T18:12:03Z
Lists: pgsql-hackers
Attachments
- v9-0001-Zero-out-VacuumCostBalance.patch (text/x-patch) patch v9-0001
- v9-0004-Autovacuum-refreshes-cost-based-delay-params-more.patch (text/x-patch) patch v9-0004
- v9-0003-VACUUM-reloads-config-file-more-often.patch (text/x-patch) patch v9-0003
- v9-0002-Make-VacuumCostActive-failsafe-aware.patch (text/x-patch) patch v9-0002
On Sat, Mar 25, 2023 at 3:03 PM Melanie Plageman <melanieplageman@gmail.com> wrote: > > On Thu, Mar 23, 2023 at 8:27 PM Melanie Plageman > <melanieplageman@gmail.com> wrote: > > On Thu, Mar 23, 2023 at 2:09 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > > > And, I was wondering if it was worth trying to split up the part that > > > > reloads the config file and all of the autovacuum stuff. The reloading > > > > of the config file by itself won't actually result in autovacuum workers > > > > having updated cost delays because of them overwriting it with > > > > wi_cost_delay, but it will allow VACUUM to have those updated values. > > > > > > It makes sense to me to have changes for overhauling the rebalance > > > mechanism in a separate patch. > > > > > > Looking back at the original concern you mentioned[1]: > > > > > > speed up long-running vacuum of a large table by > > > decreasing autovacuum_vacuum_cost_delay/vacuum_cost_delay, however the > > > config file is only reloaded between tables (for autovacuum) or after > > > the statement (for explicit vacuum). > > > > > > does it make sense to have autovac_balance_cost() update workers' > > > wi_cost_delay too? Autovacuum launcher already reloads the config file > > > and does the rebalance. So I thought autovac_balance_cost() can update > > > the cost_delay as well, and this might be a minimal change to deal > > > with your concern. This doesn't have the effect for manual VACUUM but > > > since vacuum delay is disabled by default it won't be a big problem. > > > As for manual VACUUMs, we would need to reload the config file in > > > vacuum_delay_point() as the part of your patch does. Overhauling the > > > rebalance mechanism would be another patch to improve it further. > > > > So, we can't do this without acquiring an access shared lock on every > > call to vacuum_delay_point() because cost delay is a double. > > > > I will work on a patchset with separate commits for reloading the config > > file, though (with autovac not benefitting in the first commit). > > So, I realized we could actually do as you say and have autovac workers > update their wi_cost_delay and keep the balance changes in a separate > commit. I've done this in attached v8. > > Workers take the exclusive lock to update their wi_cost_delay and > wi_cost_limit only when there is a config reload. So, there is one > commit that implements this behavior and a separate commit to revise the > worker rebalancing. So, I've attached an alternate version of the patchset which takes the approach of having one commit which only enables cost-based delay GUC refresh for VACUUM and another commit which enables it for autovacuum and makes the changes to balancing variables. I still think the commit which has workers updating their own wi_cost_delay in vacuum_delay_point() is a bit weird. It relies on no one else emulating our bad behavior and reading from wi_cost_delay without a lock and on no one else deciding to ever write to wi_cost_delay (even though it is in shared memory [this is the same as master]). It is only safe because our process is the only one (right now) writing to wi_cost_delay, so when we read from it without a lock, we know it isn't being written to. And everyone else takes a lock when reading from wi_cost_delay right now. So, it seems...not great. This approach also introduces a function that is only around for one commit until the next commit obsoletes it, which seems a bit silly. Basically, I think it is probably better to just have one commit enabling guc refresh for VACUUM and then another which correctly implements what is needed for autovacuum to do the same. Attached v9 does this. I've provided both complete versions of both approaches (v9 and v8). - Melanie
Commits
-
Fix assertion failure in heap_vacuum_rel
- 4a6603cd4650 16.0 landed
-
Fix vacuum_cost_delay check for balance calculation.
- cba3c8f6dd7f 12.15 landed
- bfac8f8bc4a4 16.0 landed
- b95f36f86131 13.11 landed
- 0e8e5e856cc3 14.8 landed
- 0319b306e87e 15.3 landed
- 0151d2c5f256 11.20 landed
-
Fix autovacuum cost debug logging
- a9781ae11ba2 16.0 landed
-
Refresh cost-based delay params more frequently in autovacuum
- 7d71d3dd080b 16.0 landed
-
Separate vacuum cost variables from GUCs
- a85c60a945ac 16.0 landed
-
Make vacuum failsafe_active globally visible
- 71a825194fd3 16.0 landed
-
Don't balance vacuum cost delay when per-table settings are in effect
- 1021bd6a89bc 9.5.0 cited