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 1pkRun-00055v-71 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 15:52:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkRul-0007fa-UD for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 15:52:43 +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 1pkRul-0007fR-Il for pgsql-hackers@lists.postgresql.org; Thu, 06 Apr 2023 15:52:43 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pkRuh-001GwY-MW for pgsql-hackers@postgresql.org; Thu, 06 Apr 2023 15:52:43 +0000 Received: by mail-pl1-x635.google.com with SMTP id kq3so37853612plb.13 for ; Thu, 06 Apr 2023 08:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680796357; x=1683388357; 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=PYIPZqgBzgKB+XhuMcWHY7WuamgQmA0duHflvMg2pls=; b=GIjPZAkoJY7r0Yh1Cp1gkY1KcE74CTQzmoib8JwDUtddam0iA+I5ozyg6Tdf0p/ilx 4zPyXcOGHo7DrkGOH6US1wRniygNODP3JRxTiL5vk9W71gAUHFUfkEcXbfZ7i87/S3jJ t21Osx3M+nMevq9MIo7U4TQ1rT9C/yRWQ5whyDBhoozC2yRyXjeM6JwF33jXb56W5w+L SBit9NR9jE/9Z774vWqE1rVkxo0npQSZOmEDPy7KFytrGWJjhEXvzMRHRnTgb8d/mFcJ 19w2+cotkoeGIDkFxQNjbjcfh+LWpIwA5Xqe5/HvrLAIbnt84jTpWvk7kccsnE/U6nLA C1mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680796357; x=1683388357; 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=PYIPZqgBzgKB+XhuMcWHY7WuamgQmA0duHflvMg2pls=; b=RCKUKtkndmyKn6mH86LW/46z3pj+2St16cFV49+um0RZV6XHHBC7VLi50dHSK/2oKM MjkYF5NJPN4HW4vU2JC8wt3SapiAu8CPz68ySkhYSReS+nf0XzJgfatshDkBEZWxj9NJ D9HrXuy0bFbgc9A0x17VMNM9BcDNlucNY6uLALZzy5FHC2/ZCq/USAFCxRe9iHJBi5u8 nB7NH0wi07FogMHWj1uLYGHUN07F33FYYRdITanUKh+fCtwVFPyqb2dGvU5VivwXFbbS oauYu/d+ilpKSiExY7cIYmTgP5177vVUsu1bnp9i/iiL1lHyYM2GA+7YWQfYi5Jpu9zU +OwQ== X-Gm-Message-State: AAQBX9ehfpTBIi7ZH/zptGm37BaYdJhfRtY84dst+C7J6YkPW4AF1b5/ 9jOInpZ7QGCkXcpLJf5tW2UV04w/0umxVa9yaS0= X-Google-Smtp-Source: AKy350b5kmCHE7U2x9ireeB+4YOQyS5FkWoqZS0C2D0jH+0MeoKfm3atMuyI+g82gs+wNUh8i3z0uh8M2+255JXtpzk= X-Received: by 2002:a17:90a:74c6:b0:244:ae2c:d5d with SMTP id p6-20020a17090a74c600b00244ae2c0d5dmr173320pjl.4.1680796357167; Thu, 06 Apr 2023 08:52:37 -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: Thu, 6 Apr 2023 11:52:25 -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 11:10=E2=80=AFPM Melanie Plageman wrote: > 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 whe= n > > > + * 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 wil= l > > 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= ... A not fully baked idea for a solution: Why not keep the balanced limit in the atomic instead of the number of workers for balance. If we expect all of the workers to have the same value for cost limit, then why would we just count the workers and not also do the division and store that in the atomic variable. We are worried about the division not being done often enough, not the number of workers being out of date. This solves that, right? - Melanie