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 1pkkHB-00045y-Ps for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Apr 2023 11:29:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkkH9-0001Ft-P7 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Apr 2023 11:29:03 +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 1pkkH9-0001Fk-Fc for pgsql-hackers@lists.postgresql.org; Fri, 07 Apr 2023 11:29:03 +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 1pkkH5-00046U-P8 for pgsql-hackers@postgresql.org; Fri, 07 Apr 2023 11:29:02 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 4C26A2F5BC71 for ; Fri, 7 Apr 2023 13:28:56 +0200 (CEST) Received: from s979.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id 3BD922E27FF1; Fri, 7 Apr 2023 13:28:56 +0200 (CEST) Received: from s473.loopia.se (unknown [172.22.191.5]) by s979.loopia.se (Postfix) with ESMTP id 3697310BC45C; Fri, 7 Apr 2023 13:28:56 +0200 (CEST) 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 s979.loopia.se ([172.22.191.5]) by s473.loopia.se (s473.loopia.se [172.22.190.13]) (amavisd-new, port 10024) with LMTP id uMeT2VqJHawl; Fri, 7 Apr 2023 13:28:55 +0200 (CEST) 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 s979.loopia.se (Postfix) with ESMTPSA id 82D2F10BC43C; Fri, 7 Apr 2023 13:28:55 +0200 (CEST) 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: Fri, 7 Apr 2023 13:28:54 +0200 Cc: Melanie Plageman , Robert Haas , Andres Freund , Tom Lane , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila Content-Transfer-Encoding: quoted-printable Message-Id: <1195917C-F076-407C-83B8-7CC8BE7A269A@yesql.se> References: <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> <20230329.173456.1185961934810139447.horikyota.ntt@gmail.com> <935191FB-083B-4060-89FC-466F61FAA391@yesql.se> <1252075.1680547394@sss.pgh.pa.us> <20230403190837.qubpnwugfe2k2g46@awork3.anarazel.de> <7E06F879-7E20-4A6A-862F-CA72CDC9A323@yesql.se> <5028847C-937A-4CC2-B127-AFF5F9FB79C5@yesql.se> <2B703533-102A-47E5-A4F7-C6A68C09BB27@yesql.se> 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 7 Apr 2023, at 08:52, Masahiko Sawada = wrote: > On Fri, Apr 7, 2023 at 8:08=E2=80=AFAM Daniel Gustafsson = wrote: >> I had another read-through and test-through of this version, and have = applied >> it with some minor changes to comments and whitespace. Thanks for = the quick >> turnaround times on reviews in this thread! >=20 > Cool! >=20 > Regarding the commit 7d71d3dd08, I have one comment: >=20 > + /* Only log updates to cost-related variables */ > + if (vacuum_cost_delay =3D=3D original_cost_delay && > + vacuum_cost_limit =3D=3D original_cost_limit) > + return; >=20 > IIUC by default, we log not only before starting the vacuum but also > when changing cost-related variables. Which is good, I think, because > logging the initial values would also be helpful for investigation. > However, I think that we don't log the initial vacuum cost values > depending on the values. For example, if the > autovacuum_vacuum_cost_delay storage option is set to 0, we don't log > the initial values. I think that instead of comparing old and new > values, we can write the log only if > message_level_is_interesting(DEBUG2) is true. That way, we don't need > to acquire the lwlock unnecessarily. And the code looks cleaner to me. > I've attached the patch (use_message_level_is_interesting.patch) That's a good idea, unless Melanie has conflicting opinions I think we = should go ahead with this. Avoiding taking a lock here is a good save. > Also, while testing the autovacuum delay with relopt > autovacuum_vacuum_cost_delay =3D 0, I realized that even if we set > autovacuum_vacuum_cost_delay =3D 0 to a table, wi_dobalance is set to > true. wi_dobalance comes from the following expression: >=20 > /* > * If any of the cost delay parameters has been set = individually for > * this table, disable the balancing algorithm. > */ > tab->at_dobalance =3D > !(avopts && (avopts->vacuum_cost_limit > 0 || > avopts->vacuum_cost_delay > 0)); >=20 > The initial values of both avopts->vacuum_cost_limit and > avopts->vacuum_cost_delay are -1. I think we should use ">=3D 0" = instead > of "> 0". Otherwise, we include the autovacuum worker working on a > table whose autovacuum_vacuum_cost_delay is 0 to the balancing > algorithm. Probably this behavior has existed also on back branches > but I haven't checked it yet. Interesting, good find. Looking quickly at the back branches I think = there is a variant of this for vacuum_cost_limit even there but needs more = investigation. -- Daniel Gustafsson