Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPNYH-004IWN-5g for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 14:35:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sPNYE-000IjF-UU for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 14:35:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPNYE-000Ij7-K2 for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 14:35:11 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPNYC-000P4e-I1 for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 14:35:10 +0000 Received: from [192.168.11.5] (p3696128-ipxg13201funabasi.chiba.ocn.ne.jp [114.164.109.128]) by oss.nttdata.com (Postfix) with ESMTPSA id 6DF826187B; Thu, 4 Jul 2024 23:35:01 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: <802ff3d5-fdc7-4b08-9046-2e9fc5fdae0e@oss.nttdata.com> Date: Thu, 4 Jul 2024 23:35:00 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal Content-Language: en-US To: Nathan Bossart Cc: pgsql-hackers@lists.postgresql.org References: <6e30082e-041b-4e31-9633-95a66de76f5d@oss.nttdata.com> From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024/07/03 23:29, Nathan Bossart wrote: > On Wed, Jul 03, 2024 at 11:08:48PM +0900, Fujii Masao wrote: >> +/* >> + * GUC check_hook for summarize_wal >> + */ >> +bool >> +check_summarize_wal(bool *newval, void **extra, GucSource source) >> +{ >> + if (*newval && wal_level == WAL_LEVEL_MINIMAL) >> + { >> + GUC_check_errmsg("WAL cannot be summarized when \"wal_level\" is \"minimal\""); >> + return false; >> + } >> + return true; >> +} > > IME these sorts of GUC hooks that depend on the value of other GUCs tend to > be quite fragile. This one might be okay because wal_level defaults to > 'replica' and because there is an additional check in postmaster.c, but > that at least deserves a comment. Yes, I didn't add a cross-check for wal_level and summarize_wal intentionally because wal_level is a PGC_POSTMASTER option, and incorrect settings of them are already checked at server startup. However, I agree that adding a comment about this would be helpful. BTW, another concern with summarize_wal is that it might not be enough to just check the summarize_wal and wal_level settings. We also need to ensure that WAL data generated with wal_level=minimal is not summarized. For example, if wal_level is changed from minimal to replica or logical, some old WAL data generated with wal_level=minimal might still exist in pg_wal. In this case, if summarize_wal is enabled, the settings of wal_level and summarize_wal is valid, but the started WAL summarizer might summarize this old WAL data unexpectedly. I haven't reviewed the code regarding how the WAL summarizer chooses its starting point, so I'm not sure if there's a real risk of summarizing WAL data generated with wal_level=minimal. > This sort of thing comes up enough that perhaps we should add a > better-supported way to deal with GUCs that depend on each other... +1 for v18 or later. However, since the reported issue is in v17, it needs to be addressed without such a improved check mechanism. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION