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 1pkG0w-0001lV-FE for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 03:10:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkG0v-0000pW-A9 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 03:10:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkG0v-0000pN-0R for pgsql-hackers@lists.postgresql.org; Thu, 06 Apr 2023 03:10:17 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pkG0s-001Abe-Dm for pgsql-hackers@postgresql.org; Thu, 06 Apr 2023 03:10:16 +0000 Received: by mail-pf1-x42a.google.com with SMTP id cm5so19112112pfb.0 for ; Wed, 05 Apr 2023 20:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680750612; x=1683342612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LDj4HtEyVcUzt8jkdyoCSmLvTCzGa8t0VtogOmEbims=; b=o2PwyWRtLMYSY9Q2eJ7ZpNbguALYVRfRW+aqwR+n/+tCKXr8AIJiZWhTsc8WZsFMMV 4JD6uDTm9Eo6UHc+zmzjRjxeSSbTBnrJkaoWRLmZ14ruFRvcDkHol3DIk66DP9D2JNXY 2gUSMhW5bgJ3VyMJxfwrv3ToEaWI/QjehEBqhjzNv0nnCV1avtBnf3VXe2gMnnWeT8s0 nkRS2+j93jVoPdrAuTfjZxlKyu60sCYc7tsL7kRO6KF2lSY8O0QEDKXCwndy2wMANyzx Ksc6DhztLLm2pJorFKowfPbmvR/Sq93KM+nEqp0scPpwDjQlE8uy/NAHbwFP/AObRBpe Wkww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680750612; x=1683342612; h=content-transfer-encoding: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=LDj4HtEyVcUzt8jkdyoCSmLvTCzGa8t0VtogOmEbims=; b=R8bRKcsaWdZ5Pycpperk5NLk/WvkFoxd4k+oG3654RKdJ3V7ZiAc0lNsDu+3O4GqIN jB5TSKgVQvj8Dqt/bEkX6E7bJeVhAH3H6jZZbsaKvSUgzyWg6kQhTxhiFwRpKTPHPulg wgS0+8QipPuJ8CamWNXmoHedR9PiBO/8OsF6a4ATOtW5LMACggpRUMayOInPG0k42R9K 59w3UdoXLGkNHCKQBXtU5xtNU0Hb9L3O+A1xvCA/XU7Wg5bbQmvk7POi/lhXN4EFH49d optgtFdARi9PGXp6W2JmY+dPKdQzPAvVSTjFaw1iwUykSNoM/kPtEL2q3/Dtd47T30Ja +nvw== X-Gm-Message-State: AAQBX9fJeWUXxYsx0jKOWYfHOzpz5uUETmQNItY/a+P3nmwQ284q8bGR ky12lQiAVg1diAVgKSdNHW6a02tzilsITs6P6oYdNigAQpQ= X-Google-Smtp-Source: AKy350bSBNqKIIXbmLykO5gcnmjnM1lBsrAwHIH9nUrogpcpnkRy+EIZNCKHnzkUHed0P03RpAH3li1bthhMauEuT90= X-Received: by 2002:a05:6a00:2e8a:b0:627:9d8a:a29c with SMTP id fd10-20020a056a002e8a00b006279d8aa29cmr4775572pfb.2.1680750612241; Wed, 05 Apr 2023 20:10:12 -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> In-Reply-To: From: Melanie Plageman Date: Wed, 5 Apr 2023 23:10:00 -0400 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Robert Haas Cc: Daniel Gustafsson , Andres Freund , Tom Lane , Masahiko Sawada , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 5, 2023 at 3:43=E2=80=AFPM Melanie Plageman wrote: > > On Wed, Apr 5, 2023 at 2:56=E2=80=AFPM Robert Haas wrote: > > > > + /* > > + * Balance and update limit values for autovacuum workers. We must > > + * always do this in case the autovacuum launcher or another > > + * autovacuum worker has recalculated the number of workers across > > + * which we must balance the limit. This is done by the launcher when > > + * launching a new worker and by workers before vacuuming each table. > > + */ > > > > I don't quite understand what's going on here. A big reason that I'm > > worried about this whole issue in the first place is that sometimes > > there's a vacuum going on a giant table and you can't get it to go > > fast. You want it to absorb new settings, and to do so quickly. I > > realize that this is about the number of workers, not the actual cost > > limit, so that makes what I'm about to say less important. But ... is > > this often enough? Like, the time before we move onto the next table > > could be super long. The time before a new worker is launched should > > be ~autovacuum_naptime/autovacuum_max_workers or ~20s with default > > settings, so that's not horrible, but I'm kind of struggling to > > understand the rationale for this particular choice. Maybe it's fine. > > VacuumUpdateCosts() also calls AutoVacuumUpdateCostLimit(), so this will > happen if a config reload is pending the next time vacuum_delay_point() > is called (which is pretty often -- roughly once per block vacuumed but > definitely more than once per table). > > Relevant code is at the top of vacuum_delay_point(): > > if (ConfigReloadPending && IsAutoVacuumWorkerProcess()) > { > ConfigReloadPending =3D false; > ProcessConfigFile(PGC_SIGHUP); > VacuumUpdateCosts(); > } > Gah, I think I misunderstood you. You are saying that only calling AutoVacuumUpdateCostLimit() after napping while vacuuming a table may not be enough. The frequency at which the number of workers changes will likely be different. This is a good point. It's kind of weird to call AutoVacuumUpdateCostLimit() only after napping..= . Hmm. Well, I don't think we want to call AutoVacuumUpdateCostLimit() on every call to vacuum_delay_point(), though, do we? It includes two atomic operations. Maybe that pales in comparison to what we are doing on each page we are vacuuming. I haven't properly thought about it. Is there some other relevant condition we can use to determine whether or not to call AutoVacuumUpdateCostLimit() on a given invocation of vacuum_delay_point()? Maybe something with naptime/max workers? I'm not sure if there is a more reliable place than vacuum_delay_point() for us to do this. I poked around heap_vacuum_rel(), but I think we would want this cost limit update to happen table AM-agnostically. Thank you for bringing this up! - Melanie