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 1pkfyU-0001hw-Ey for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Apr 2023 06:53:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkfyT-0007r2-8U for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Apr 2023 06:53:29 +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 1pkfyS-0007qt-Oz for pgsql-hackers@lists.postgresql.org; Fri, 07 Apr 2023 06:53:28 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pkfyQ-0001ak-7p for pgsql-hackers@postgresql.org; Fri, 07 Apr 2023 06:53:27 +0000 Received: by mail-ot1-x331.google.com with SMTP id r17-20020a05683002f100b006a131458abfso19157845ote.2 for ; Thu, 06 Apr 2023 23:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680850405; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9xcE8/LPQt+T5wEtLWHkQo7zxn6m+N1psoLSMiUbrbU=; b=Ehl67hGHANAhSaQp2lzOSlvvhWyzDWhH8x+6zQ7iudaPJiJI23IkSOt4M3i4ihug1O EDVJbQOqRsrDRL9Kb6MlqQycaObt35670p5smCBjiuP3D6wv1yTMfU148DrPOeZCTFnj 9azWmzeojivJtSQvYLbadOsQhVTjXt3NyH2fItHHpOoa+vOy5XzFa+xM3x2poA77rh6i 9lPatiXInlFUqePvYYROV1V6WG3HfrZIQU9mTGgr8zK44IOg8c+8JVdft2UPfrnYR/e+ LvA3Yo9c1ue3XgY8/hM6fybUW6PXsHq+q/XnezDGoMYCkSjoyViotjYlh1wit2PRu/nc o55Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680850405; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9xcE8/LPQt+T5wEtLWHkQo7zxn6m+N1psoLSMiUbrbU=; b=xX2Rr0SN7W6WgJEMU+9nPQHMM5WjeNgFkwUDAU0bNF8k5FkAd6CdRswBSE8/lAxf5i uhLwp+FeOJSr0nAdZIZcikT5x7fwwjE2zgkwTv1PgLjWHzDS2n3s5Utmq6/c6gAcAaXj mlBIgiaqOK1N8pt3BzFwyYeOCBeAX42VGERE9Gxcg7CAe5eofepkHKrz9sjhsOf0GDtX kwRpwmOVNV51pkqp9PBrT9qVkxZaTw63pNipAibkNU5CVyrtCzRffwk+De1cj0u7pdv0 TYTRRzVw2tWXBGTMzU4mUyVFgfY+8LtALFO6t5IotgtRv+TQCdIPtGuF5/tA5s+jH6m7 0jAQ== X-Gm-Message-State: AAQBX9dPqwQcv7L26d3mGLs/AKEv6188uSGixcPtxwfgJKHhe6ZiIGmj 38Ihuz6vs8ZV4rCUbxPF7eUxMN/BqrNnBcbaTvWZfZnX X-Google-Smtp-Source: AKy350Y2LcmshdeRXJZ7J4DW7E0eIpDu5i6KUTLJ2Auw4fHRpbzDBigRUkLcepVe6mttqHQ1PFI5lD1HFf49rZeJyEo= X-Received: by 2002:a05:6830:1bdc:b0:696:f275:a60d with SMTP id v28-20020a0568301bdc00b00696f275a60dmr350637ota.7.1680850405453; Thu, 06 Apr 2023 23:53:25 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <2B703533-102A-47E5-A4F7-C6A68C09BB27@yesql.se> From: Masahiko Sawada Date: Fri, 7 Apr 2023 15:52:49 +0900 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Daniel Gustafsson Cc: Melanie Plageman , Robert Haas , Andres Freund , Tom Lane , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila Content-Type: multipart/mixed; boundary="00000000000056fcf705f8b97b2a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000056fcf705f8b97b2a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 7, 2023 at 8:08=E2=80=AFAM Daniel Gustafsson = wrote: > > > On 7 Apr 2023, at 00:12, Melanie Plageman w= rote: > > > > On Thu, Apr 6, 2023 at 5:45=E2=80=AFPM Daniel Gustafsson wrote: > >> > >>> On 6 Apr 2023, at 23:06, Melanie Plageman = wrote: > >> > >>> Autovacuum workers, at the end of VacuumUpdateCosts(), check if cost > >>> limit or cost delay have been changed. If they have, they assert that > >>> they don't already hold the AutovacuumLock, take it in shared mode, a= nd > >>> do the logging. > >> > >> Another idea would be to copy the values to local temp variables while= holding > >> the lock, and release the lock before calling elog() to avoid holding = the lock > >> over potential IO. > > > > Good idea. I've done this in attached v19. > > Also I looked through the docs and everything still looks correct for > > balancing algo. > > I had another read-through and test-through of this version, and have app= lied > it with some minor changes to comments and whitespace. Thanks for the qu= ick > turnaround times on reviews in this thread! Cool! Regarding the commit 7d71d3dd08, I have one comment: + /* 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; 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) 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: /* * If any of the cost delay parameters has been set individually fo= r * this table, disable the balancing algorithm. */ tab->at_dobalance =3D !(avopts && (avopts->vacuum_cost_limit > 0 || avopts->vacuum_cost_delay > 0)); 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. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com --00000000000056fcf705f8b97b2a Content-Type: application/octet-stream; name="fix.patch" Content-Disposition: attachment; filename="fix.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lg66w1db1 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3Bvc3RtYXN0ZXIvYXV0b3ZhY3V1bS5jIGIvc3JjL2Jh Y2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKaW5kZXggNTNjOGY4ZDc5Yy4uMjAzNmIzOWFk NSAxMDA2NDQKLS0tIGEvc3JjL2JhY2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKKysrIGIv c3JjL2JhY2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKQEAgLTI5NTEsOCArMjk1MSw4IEBA IHRhYmxlX3JlY2hlY2tfYXV0b3ZhYyhPaWQgcmVsaWQsIEhUQUIgKnRhYmxlX3RvYXN0X21hcCwK IAkJICogdGhpcyB0YWJsZSwgZGlzYWJsZSB0aGUgYmFsYW5jaW5nIGFsZ29yaXRobS4KIAkJICov CiAJCXRhYi0+YXRfZG9iYWxhbmNlID0KLQkJCSEoYXZvcHRzICYmIChhdm9wdHMtPnZhY3V1bV9j b3N0X2xpbWl0ID4gMCB8fAotCQkJCQkJIGF2b3B0cy0+dmFjdXVtX2Nvc3RfZGVsYXkgPiAwKSk7 CisJCQkhKGF2b3B0cyAmJiAoYXZvcHRzLT52YWN1dW1fY29zdF9saW1pdCA+PSAwIHx8CisJCQkJ CQkgYXZvcHRzLT52YWN1dW1fY29zdF9kZWxheSA+PSAwKSk7CiAJfQogCiAJaGVhcF9mcmVldHVw bGUoY2xhc3NUdXApOwo= --00000000000056fcf705f8b97b2a Content-Type: application/octet-stream; name="use_message_level_is_interesting.patch" Content-Disposition: attachment; filename="use_message_level_is_interesting.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lg66w1d90 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3Bvc3RtYXN0ZXIvYXV0b3ZhY3V1bS5jIGIvc3JjL2Jh Y2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKaW5kZXggNTNjOGY4ZDc5Yy4uNDQ0OTdmNjcz NCAxMDA2NDQKLS0tIGEvc3JjL2JhY2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKKysrIGIv c3JjL2JhY2tlbmQvcG9zdG1hc3Rlci9hdXRvdmFjdXVtLmMKQEAgLTE3ODUsOSArMTc4NSw2IEBA IEZyZWVXb3JrZXJJbmZvKGludCBjb2RlLCBEYXR1bSBhcmcpCiB2b2lkCiBWYWN1dW1VcGRhdGVD b3N0cyh2b2lkKQogewotCWRvdWJsZQkJb3JpZ2luYWxfY29zdF9kZWxheSA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