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 1phiTy-0002Xe-FM for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 02:57:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phiTx-0000i9-84 for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 02:57:45 +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 1phiTw-0000i0-VW for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 02:57:44 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1phiTu-0005lV-IY for pgsql-hackers@postgresql.org; Thu, 30 Mar 2023 02:57:44 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-177b78067ffso18383861fac.7 for ; Wed, 29 Mar 2023 19:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680145062; 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=BnqUvZ7jrbldLdaTE2EvrH7nXgIJW9ma8Ss2ViMHi3M=; b=Iot14Xk2Ynshz9oWY2ufSB2zcNptxEyvIQbdn8o3mtolu1BglOVaYNH6AwnJUU0CEg VvAOgU2vVreUMSoDb+7WQr2DvMHJ1O+QYdpzBPvv0xoKFWrprFvev45TtWGrJAKVY6tI uK7WQNMnW470koRDMDAoR8uLHDRhn1+kRmTM+xi7uOruZU7ulvpzFEr3tXLrhLnVLTcn e8K92+fM3FsUaMDF7Q8YnfTPVs518oam+3ylr2j6UJLHgBXHsIKU4SYQSDL3WbQI3qZE EDFG13VCC53nCmd3AHj/YinUnb+bQcGuduG1JwjpC1+DaLKFXuS6PiXSgqyxRshl9pJR 5F3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680145062; 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=BnqUvZ7jrbldLdaTE2EvrH7nXgIJW9ma8Ss2ViMHi3M=; b=CGoODioB416p88cXLUM99bLymF0KiGBZzRt/xqW53vBXmDDjLQMqSqUl0cDdTuq+D8 Qn7+F3UXr5dTP+lxOv7IIZsq2YRHabdiIDtYI6wVrs7v5je0dbDhKTKEQlSOK2hPTn5/ zDuJp9AttdwLfMD/fC5ysLlXlpm9gPtHi3JhurLImDqMydHYIgVuQYY/CbdCfR2ExPGR JV+ZbPM9NBEoBPO8B4/0T3M7LGIomvkEyfMAm56oUwf1ufAfSgPWA3+bBgZbOURKAgbh mWDQOWolyhaY2Id99hGhTLKJZaFoTRPrPgi6QSe3rVdyULg5mKSz07q4yKZf5AH8NDMI BHGw== X-Gm-Message-State: AAQBX9fj2SwYG7I/uqyo+y4ndpUeh1OH3p8Mj+bRJX0vfcX5U60L2FlG 7Uyc++5U6u3cnHg8iVLjbgMD2uUI1YkCzhJ62Y0= X-Google-Smtp-Source: AKy350YdLeZldoX/h7DbRAN5F/fQLif+pByOCtLIg1zOVeGNy1yl2S0ILQHoZtykr41FRaKJmaqnxQvaxvF01kASMQE= X-Received: by 2002:a05:6870:1194:b0:17b:7376:8c82 with SMTP id 20-20020a056870119400b0017b73768c82mr7680877oau.1.1680145061871; Wed, 29 Mar 2023 19:57:41 -0700 (PDT) MIME-Version: 1.0 References: <20230329.120908.350115307125624430.horikyota.ntt@gmail.com> <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> <20230329.173456.1185961934810139447.horikyota.ntt@gmail.com> In-Reply-To: From: Masahiko Sawada Date: Thu, 30 Mar 2023 11:57:05 +0900 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Melanie Plageman Cc: Kyotaro Horiguchi , daniel@yesql.se, pgsql-hackers@postgresql.org, andres@anarazel.de, amit.kapila16@gmail.com 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 Hi, Thank you for updating the patches. On Thu, Mar 30, 2023 at 5:01=E2=80=AFAM Melanie Plageman wrote: > > Thanks for the detailed review! > > On Tue, Mar 28, 2023 at 11:09=E2=80=AFPM Kyotaro Horiguchi > wrote: > > > > At Tue, 28 Mar 2023 20:35:28 -0400, Melanie Plageman wrote in > > > On Tue, Mar 28, 2023 at 4:21=E2=80=AFAM Kyotaro Horiguchi wrote: > > > > > > > > At Mon, 27 Mar 2023 14:12:03 -0400, Melanie Plageman wrote in > > > > > > > > 0002: > > > > > > > > I felt a bit uneasy on this. It seems somewhat complex (and makes t= he > > > > succeeding patches complex), > > > > > > Even if we introduced a second global variable to indicate that fails= afe > > > mode has been engaged, we would still require the additional checks > > > of VacuumCostInactive. > > > > > > > has confusing names, > > > > > > I would be happy to rename the values of the enum to make them less > > > confusing. Are you thinking "force" instead of "locked"? > > > maybe: > > > VACUUM_COST_FORCE_INACTIVE and > > > VACUUM_COST_INACTIVE > > > ? > > > > > > > and doesn't seem like self-contained. > > > > > > By changing the variable from VacuumCostActive to VacuumCostInactive,= I > > > have kept all non-vacuum code from having to distinguish between it > > > being inactive due to failsafe mode or due to user settings. > > > > My concern is that VacuumCostActive is logic-inverted and turned into > > a ternary variable in a subtle way. The expression > > "!VacuumCostInactive" is quite confusing. (I sometimes feel the same > > way about "!XLogRecPtrIsInvalid(lsn)", and I believe most people write > > it with another macro like "lsn !=3D InvalidXLogrecPtr"). Additionally, > > the constraint in this patch will be implemented as open code. So I > > wanted to suggest something like the attached. The main idea is to use > > a wrapper function to enforce the restriction, and by doing so, we > > eliminated the need to make the variable into a ternary without a good > > reason. > > So, the rationale for making it a ternary is that the variable is the > combination of two pieces of information which has only has 3 valid > states: > failsafe inactive + cost active =3D cost active > failsafe inactive + cost inactive =3D cost inactive > failsafe active + cost inactive =3D cost inactive and locked > the fourth is invalid > failsafe active + cost active =3D invalid > That is harder to enforce with two variables. > Also, the two pieces of information are not meaningful individually. > So, I thought it made sense to make a single variable. > > Your suggested patch introduces an additional variable which shadows > LVRelState->failsafe_active but doesn't actually get set/reset at all of > the correct places. If we did introduce a second global variable, I > don't think we should also keep LVRelState->failsafe_active, as keeping > them in sync will be difficult. > > As for the double negative (!VacuumCostInactive), I agree that it is not > ideal, however, if we use a ternary and keep VacuumCostActive, there is > no way for non-vacuum code to treat it as a boolean. > With the ternary VacuumCostInactive, only vacuum code has to know about > the distinction between inactive+failsafe active and inactive+failsafe > inactive. As another idea, why don't we use macros for that? For example, suppose VacuumCostStatus is like: typedef enum VacuumCostStatus { VACUUM_COST_INACTIVE_LOCKED =3D 0, VACUUM_COST_INACTIVE, VACUUM_COST_ACTIVE, } VacuumCostStatus; VacuumCostStatus VacuumCost; non-vacuum code can use the following macros: #define VacuumCostActive() (VacuumCost =3D=3D VACUUM_COST_ACTIVE) #define VacuumCostInactive() (VacuumCost <=3D VACUUM_COST_INACTIVE) // or we can use !VacuumCostActive() instead. Or is there any reason why we need to keep VacuumCostActive and treat it as a boolean? Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com