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 1mL7D0-0002rq-Tc for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Aug 2021 17:06:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mL7Cy-0000Fg-WF for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Aug 2021 17:06:01 +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 1mL7Cy-0000FI-OT for pgsql-hackers@lists.postgresql.org; Tue, 31 Aug 2021 17:06:00 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mL7Cw-0002lp-4A for pgsql-hackers@postgresql.org; Tue, 31 Aug 2021 17:06:00 +0000 Received: from hrk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id EE3EF60762; Wed, 1 Sep 2021 02:05:53 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at oss.nttdata.com Subject: Re: Improve logging when using Huge Pages To: Julien Rouhaud , "Shinoda, Noriyoshi (PN Japan FSIP)" Cc: "pgsql-hackers@postgresql.org" References: From: Fujii Masao Message-ID: <7e5b9f6d-1db9-d1e2-3bd8-ef65f24b35be@oss.nttdata.com> Date: Wed, 1 Sep 2021 02:05:53 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/08/31 15:57, Julien Rouhaud wrote: > On Tue, Aug 31, 2021 at 1:37 PM Shinoda, Noriyoshi (PN Japan FSIP) > wrote: >> >> In the current version, when GUC huge_pages=try, which is the default setting, no log is output regardless of the success or failure of the HugePages acquisition. If you want to output logs, you need to set log_min_messages=DEBUG3, but it will output a huge amount of extra logs. >> With huge_pages=try setting, if the kernel parameter vm.nr_hugepages is not enough, the administrator will not notice that HugePages is not being used. >> I think it should output a log if HugePages was not available. +1 - elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m", + elog(WARNING, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m", elog() should be used only for internal errors and low-level debug logging. So per your proposal, elog() is not suitable here. Instead, ereport() should be used. The log level should be LOG rather than WARNING because this message indicates the information about server activity that administrators are interested in. The message should be updated so that it follows the Error Message Style Guide. https://www.postgresql.org/docs/devel/error-style-guide.html With huge_pages=on, if shared memory fails to be allocated, the error message is reported currently. Even with huge_page=try, this error message should be used to simplify the code as follows? errno = mmap_errno; - ereport(FATAL, + ereport((huge_pages == HUGE_PAGES_ON) ? FATAL : LOG, (errmsg("could not map anonymous shared memory: %m"), (mmap_errno == ENOMEM) ? errhint("This error usually means that PostgreSQL's request " > I agree that the message should be promoted to a higher level. But I > think we should also make that information available at the SQL level, > as the log files may be truncated / rotated before you need the info, > and it can be troublesome to find the information at the OS level, if > you're lucky enough to have OS access. +1 Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION