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 1qkZtr-00F0gp-CL for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 00:56:35 +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 1qkZtp-00C6UK-Mj for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 00:56:33 +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 1qkZtp-00C6U8-C8 for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 00:56:33 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkZtm-007O4U-9r for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 00:56:32 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 1B21332009E5; Sun, 24 Sep 2023 20:56:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 24 Sep 2023 20:56:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1695603387; x=1695689787; bh=ss oJY1+sQW9/dSLpC25Vr+HMLrhBKD8h2FoPaPJ0/yY=; b=fQAhCHbK62PWQJSWEo Xp230L3XWZf4uHrQCKNvb/reny24tglF/fXBWgLq+O2IxxzZCn5KvdPq3FY0DzM1 9DMWUoVjW9i0qQ5WxjZANNMO0B20hEFy/OA41+eNFzaHIvdw9mAvW0BBf7L/pEkJ NHwf+Kob8+QLINz9qQi72/z9ymSXSMUzmal8E3WfGN2PV8rKC5XaIY6xiuiXc6kj npRsYZwXjMlpukah+OVp32ww7lD/9XXlTON54oY0TDvbglMX+CEP1qPEiqnwkeEP wV1CilNsKfHunw4GOecyktbi94wGnqFyL07xnZYv/x6Q0x6FEY4gHkPJuRWjyVn9 yxMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1695603387; x=1695689787; bh=ssoJY1+sQW9/d SLpC25Vr+HMLrhBKD8h2FoPaPJ0/yY=; b=AYJhaMYbh9Nx6Sts+RXfDk4BrJ0GF Aa/tbR+cHdZGsh/ksUwWGfhfHrloTuN9SeC1WYxEUvlptX1D7fGU41eFaAYjBapQ 8tgaP4rTKGz3ztMlCswoYRQre2ChyGGb57vljK5NgyN3l2tz9CnZM2fMP9javMYq A+3XyHtDjZLj0+8NbIHJaKAfEucHGfKi7UHCGbYaQ6mOs+nANVDjo6CZSx8nBBz3 hLtd0h6W77gfN5Z3z6i1CAjSHFtoaFAt4RX3nj75sDLjPgzda6mk+Lc3r6HNj4at 0EbrO+KNF0jYbly2Em14F+Bohhdglfq/2b/fgt+4K0dsHoDTRc9BMUFTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudelfedggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghq uhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvg hrnhepteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitg hhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 24 Sep 2023 20:56:26 -0400 (EDT) Date: Mon, 25 Sep 2023 09:56:22 +0900 From: Michael Paquier To: Ryoga Yoshida Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Doesn't pgstat_report_wal() handle the argument "force" incorrectly Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Jp8p3Uy7gkuSfSUV" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Jp8p3Uy7gkuSfSUV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 22, 2023 at 01:58:37PM +0900, Ryoga Yoshida wrote: > 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. It seems to me that you are right here. It would make sense to me to say that force=true is equivalent to nowait=false, as in "I'm OK to wait on the lockas I want to make sure that the stats are flushed at this point". Currently force=true means nowait=true, as in "I'm OK to not have the stats flushed if I cannot take the lock". Seeing the three callers of pgstat_report_wal(), the checkpointer wants to force its way twice, and the WAL writer does not care if they are not flushed immediately at it loops forever in this path. A comment at the top of pgstat_report_wal() would be nice to document that a bit better, at least. -- Michael --Jp8p3Uy7gkuSfSUV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmUQ2rYACgkQnvQgOdby QH2YTw/+J5zagtF63uzPCQADdPkztCmcb6MU89ru/S0/HsJCD26y3RAISnFWAThh UeNUzXCE/BcN5g4Yg+mcPOwyVCNZxrfvOgL5CNPsLkxumNWJ14bSoJILdSaprp5u KXQ0JRxOBWXcB8OAOf/LESyu+tATor/wyZC+jqwxBoms8V4VXM3WuXEnFKsLiCKw xdFr6a9tKLAef4NlKkkt1jigOvv10aNtUNgv3a0ExDuymqgeh7Vy2BQs1IH4/1pD xNsJi14sQsRL2NPABDHMHPoilnKh+/+eR8FmjOIMJB3+cBybpAWX0JIgbv1/15nj I6tpYY2AvLCz2OAzXJ5hL6Nkt9VWys9v0DKyc3UTBLvAa0yv8UMZUljCaM/y4hid qeESFn3TeluZ3UAMT+dGWMnIQb2ruiFvSiJ66OE/CkgHseJ/SWZzUtI0zYEf0ntl chZGjiKPDDtL5cW6dJZ6Rd04oVXxwl2XpJpbfUWDA44ffn8W+YtSBo1p6k+YI9Lh WgRgsj61uuSsjgp3lzmvX8eK+zOIFwe8TNWbBgtAGsLqn0oUa8dcIfSgkNisAhkH 8Nfr6OXZ5CKsdIhUqV6QEs1VVSRTpebR3yu2vJaPepdqG29/tANA8OEpsAI+RS1B yilyhi0BJbJy1J13U3sduS6K5HG0OdJZ6/irD+f/IV8W6S+28pA= =xdzN -----END PGP SIGNATURE----- --Jp8p3Uy7gkuSfSUV--