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 1qjYFe-00BLpf-RL for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Sep 2023 04:58:50 +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 1qjYFd-000wK2-1U for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Sep 2023 04:58:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjYFc-000wJp-Mr for pgsql-hackers@lists.postgresql.org; Fri, 22 Sep 2023 04:58:48 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjYFW-005xnm-HX for pgsql-hackers@lists.postgresql.org; Fri, 22 Sep 2023 04:58:47 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 8043360833 for ; Fri, 22 Sep 2023 13:58:37 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 22 Sep 2023 13:58:37 +0900 From: Ryoga Yoshida To: pgsql-hackers@lists.postgresql.org Subject: Doesn't pgstat_report_wal() handle the argument "force" incorrectly User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: bt23yoshidar@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, pgstat_report_wal() calls pgstat_flush_wal() and pgstat_flush_io(). When calling them, pgstat_report_wal() specifies its argument "force" as the argument of them, as follows. But according to the code of pgstat_flush_wal() and pgstat_flush_io(), their argument is "nowait" and its meaning seems the opposite of "force". This means that, even when checkpointer etc calls pgstat_report_wal() with force=true to forcibly flush the statistics, pgstat_flush_wal() and pgstat_flush_io() skip flushing the statistics if they fail to acquire the lock immediately because they are called with nowait=true. This seems unexpected behavior and a bug. void pgstat_report_wal(bool force) { pgstat_flush_wal(force); pgstat_flush_io(force); } BTW, pgstat_report_stat() treats "nowait" and "force" as the opposite one, as follows. /* don't wait for lock acquisition when !force */ nowait = !force; Ryoga Yoshida