Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfNk8-00051O-2f for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Mar 2023 16:24:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pfNk5-0007RP-2s for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Mar 2023 16:24:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfNk4-0007RF-PN for pgsql-hackers@lists.postgresql.org; Thu, 23 Mar 2023 16:24:44 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfNk1-0000pN-3r for pgsql-hackers@postgresql.org; Thu, 23 Mar 2023 16:24:43 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 8F0322F872B9 for ; Thu, 23 Mar 2023 17:24:37 +0100 (CET) Received: from s899.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 74F9F2E29285; Thu, 23 Mar 2023 17:24:37 +0100 (CET) Received: from s473.loopia.se (unknown [172.22.191.6]) by s899.loopia.se (Postfix) with ESMTP id 702012C8BA69; Thu, 23 Mar 2023 17:24:37 +0100 (CET) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s899.loopia.se ([172.22.191.6]) by s473.loopia.se (s473.loopia.se [172.22.190.13]) (amavisd-new, port 10024) with LMTP id U_UCGPZFtFXP; Thu, 23 Mar 2023 17:24:36 +0100 (CET) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s899.loopia.se (Postfix) with ESMTPSA id B3BEF2C8BA6B; Thu, 23 Mar 2023 17:24:36 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: Should vacuum process config file reload more often From: Daniel Gustafsson In-Reply-To: Date: Thu, 23 Mar 2023 17:24:36 +0100 Cc: Melanie Plageman , PostgreSQL Hackers , Andres Freund , Amit Kapila Content-Transfer-Encoding: quoted-printable Message-Id: <28639967-F021-4772-A40C-0E6D348CF941@yesql.se> References: To: Masahiko Sawada X-Mailer: Apple Mail (2.3696.120.41.1.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 23 Mar 2023, at 07:08, Masahiko Sawada = wrote: > On Sun, Mar 19, 2023 at 7:47=E2=80=AFAM Melanie Plageman = wrote: > It makes sense to me that we need to reload the config file even when > vacuum-delay is disabled. But I think it's not convenient for users > that we don't reload the configuration file once the failsafe is > triggered. I think users might want to change some GUCs such as > log_autovacuum_min_duration. I agree with this. >> On an unrelated note, I was wondering if there were any docs anywhere >> that should be updated to go along with this. >=20 > The current patch improves the internal mechanism of (re)balancing > vacuum-cost but doesn't change user-visible behavior. I don't have any > idea so far that we should update somewhere in the doc. I had a look as well and can't really spot anywhere where the current = behavior is detailed, so there is little to update. On top of that, I also don't = think it's worth adding this to the docs. >> 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. >=20 > It makes sense to me to have changes for overhauling the rebalance > mechanism in a separate patch. It would for sure be worth considering,=20 +bool VacuumFailsafeActive =3D false; This needs documentation, how it's used and how it relates to = failsafe_active in LVRelState (which it might replace(?), but until then). + pg_atomic_uint32 nworkers_for_balance; This needs a short oneline documentation update to the struct comment. - double wi_cost_delay; - int wi_cost_limit; - int wi_cost_limit_base; This change makes the below comment in do_autovacuum in need of an = update: /* * Remove my info from shared memory. We could, but intentionally. * don't, clear wi_cost_limit and friends --- this is on the * assumption that we probably have more to do with similar cost * settings, so we don't want to give up our share of I/O for a very * short interval and thereby thrash the global balance. */ + if (av_table_option_cost_delay >=3D 0) + VacuumCostDelay =3D av_table_option_cost_delay; + else + VacuumCostDelay =3D autovacuum_vac_cost_delay >=3D 0 ? + autovacuum_vac_cost_delay : VacuumCostDelay; While it's a matter of personal preference, I for one would like if we = reduced the number of ternary operators in the vacuum code, especially those = mixed into if statements. The vacuum code is full of this already though so this = isn't less of an objection (as it follows style) than an observation. + * note: in cost_limit, zero also means use value from elsewhere, = because + * zero is not a valid value. ... + int vac_cost_limit =3D autovacuum_vac_cost_limit > 0 ? + autovacuum_vac_cost_limit : VacuumCostLimit; Not mentioning the fact that a magic value in a GUC means it's using the = value from another GUC (which is not great IMHO), it seems we are using zero = as well as -1 as that magic value here? (not introduced in this patch.) The = docs does AFAICT only specify -1 as that value though. Am I missing something or = is the code and documentation slightly out of sync? I need another few readthroughs to figure out of VacuumFailsafeActive = does what I think it does, and should be doing, but in general I think this is a = good idea and a patch in good condition close to being committable. -- Daniel Gustafsson=