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 1pflCt-0004Sv-Az for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Mar 2023 17:28:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pflCs-0004a9-4C for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Mar 2023 17:28:02 +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 1pflCr-0004a0-Ox for pgsql-hackers@lists.postgresql.org; Fri, 24 Mar 2023 17:28:01 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pflCp-0004Yf-8B for pgsql-hackers@postgresql.org; Fri, 24 Mar 2023 17:28:01 +0000 Received: by mail-pf1-x435.google.com with SMTP id i15so1719069pfo.8 for ; Fri, 24 Mar 2023 10:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679678877; 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=fktJhc2djGTMm0NEOwrSkPlCl6o2wYSJKr1XOyNIMSQ=; b=azHo3CWn1/ijFg/bOgtkQpa3+bOgazrsvOMI7JAToK9XiuOcKWWEH/aBFiiiPxkbil wEQOgtWM4E42b/NCwy5k7luDeCRnhDwRYhsn9sGPqCpsjFca3Kjq+1dYHurlJ/LujgUh tUE2EPLmr6dI0DMTSCpzdnZi0ph2eafgu1SIkFkZB/E51wjUSLH7IGaT+7xpXtEHi2Xr aihPligPyiayfoFFK1OTqL9xq8RPAMsKz48VWeyQmod/8duQXtM/LINBvjkQ6ffhVsjQ F7ynAPwZTibEkrcF2hFqGjowGpolF0xZ3AfOUFo0zX6rOviCSIONz6iT0aRqkU4KOfbq Jv7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679678877; 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=fktJhc2djGTMm0NEOwrSkPlCl6o2wYSJKr1XOyNIMSQ=; b=xTIdbXpG4spqNCF9tazpFu7jKR+QC/Ie+Dv6MIoFucyr36dJL+eQ/NwCghkEuP1Vcq XIA8mqwMBypNinl3imoETxOzBnui7BZIgdfCPGB+hJ/tLV8SEfeZMVPXHjZiloEnbBL0 Ti3xG8hI4VOvO/vKvhbaCuxxAAzszJcVuCecuWj9ze9UTtH6nVKwmKM7/7jKJ+i4ZJhd iO77VrkPCYa6Xe3fAGjBijHDb8xGAz/xUwN9olHocGZW1ydCBeFcVwygZSknyfSO16bH 77fEP3+cX6XeMqlsH/cRt79H/cbdv7kqoUPeRTEsMaB/74hpBlCGRFDVyVtoZNI2OOS7 izoQ== X-Gm-Message-State: AAQBX9cqY3azVPHkpFUKs4ttsoS6vChfxXW9L7P0py2qsjZe3gQSDQtN D7q9UXnLqL5Pn9Wm8GoLZBUdBq2Plssdy6dIYhk= X-Google-Smtp-Source: AKy350bFvw1eV4odAtRRLc9V6XvQ2poo1vXgkI2U00OMHk8oRcWWhRyUAIdzr5Px+wy39I6BwMP3n8ge6RjXRzGWyII= X-Received: by 2002:a63:e74a:0:b0:503:99d5:4ef7 with SMTP id j10-20020a63e74a000000b0050399d54ef7mr859752pgk.12.1679678876797; Fri, 24 Mar 2023 10:27:56 -0700 (PDT) MIME-Version: 1.0 References: <28639967-F021-4772-A40C-0E6D348CF941@yesql.se> In-Reply-To: From: Melanie Plageman Date: Fri, 24 Mar 2023 13:27:45 -0400 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Masahiko Sawada Cc: Daniel Gustafsson , PostgreSQL Hackers , Andres Freund , 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 Fri, Mar 24, 2023 at 1:21=E2=80=AFAM Masahiko Sawada wrote: > > On Fri, Mar 24, 2023 at 9:27=E2=80=AFAM Melanie Plageman > wrote: > > > > On Thu, Mar 23, 2023 at 2:09=E2=80=AFAM Masahiko Sawada wrote: > > > On Sun, Mar 19, 2023 at 7:47=E2=80=AFAM Melanie Plageman wrote: > > > Do we need to calculate the number of workers running with > > > nworkers_for_balance by iterating over the running worker list? I > > > guess autovacuum workers can increment/decrement it at the beginning > > > and end of vacuum. > > > > I don't think we can do that because if a worker crashes, we have no wa= y > > of knowing if it had incremented or decremented the number, so we can't > > adjust for it. > > What kind of crash are you concerned about? If a worker raises an > ERROR, we can catch it in PG_CATCH() block. If it's a FATAL, we can do > that in FreeWorkerInfo(). A PANIC error ends up crashing the entire > server. Yes, but what about a worker that segfaults? Since table AMs can define relation_vacuum(), this seems like a real possibility. I'll address your other code feedback in the next version. I realized nworkers_for_balance should be initialized to 0 and not 1 -- 1 is misleading since there are often 0 autovac workers. We just never want to use nworkers_for_balance when it is 0. But, workers put a floor of 1 on the number when they divide limit/nworkers_for_balance (since they know there must be at least one worker right now since they are a worker). I thought about whether or not they should call autovac_balance_cost() if they find that nworkers_for_balance is 0 when updating their own limit, but I'm not sure. > > > 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. > > Another approach would be to make VacuumCostActive a ternary value: > on, off, and never. When we trigger the failsafe mode we switch it to > never, meaning that it never becomes active even after reloading the > config file. A good point is that we don't need to add a new global > variable, but I'm not sure it's better than the current approach. Hmm, this is interesting. I don't love the word "never" since it kind of implies a duration longer than the current table being vacuumed. But we could find a different word or just document it well. For clarity, we might want to call it failsafe_mode or something. I wonder if the primary drawback to converting LVRelState->failsafe_active to a global VacuumFailsafeActive is just the general rule of limiting scope to the minimum needed. - Melanie