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 1qkcZe-00FG9I-85 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 03:47:54 +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 1qkcZb-00D9JT-Nv for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 03:47:51 +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 1qkcZb-00D9Ix-Ak for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 03:47:51 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkcZY-006TbH-ND for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 03:47:50 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 00FCD320096D; Sun, 24 Sep 2023 23:47:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 24 Sep 2023 23:47:47 -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=1695613666; x=1695700066; bh=DE y9BA7bwKLx55LCNufwF7JIexvGSYemdUCbZVNABsk=; b=rHNIRtOBsXIxZ28d4t SotvP4bimtLG9yyy4Qt46yphGLNRGD536CaotRJK0FIXMuz5/6nzHQIrRftH2XMr bJrlbpRNbJo5dBWvb8ktfmk6Dw+oWju12nmax5hC0rqqkMUDFvBTbQc9EvNMsHJm WjSeoFY0ULfyJwJQc05vioFdXBTMDvcCXfkwSUEqLfTWkIewb2edXJvTpCV4MmWV o6MuDcQj64wjNAuCVpXJLRCd22+/y27yWfESwvOIk+j8wIRz/xFSyOZbAnvGfy6s cV9jtJ0GU8ESPrx4fxggVN2VcDXpG6dnX5WuIZrYiFJUJ8jE1bPT4qPSMPvm18h5 yskQ== 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=1695613666; x=1695700066; bh=DEy9BA7bwKLx5 5LCNufwF7JIexvGSYemdUCbZVNABsk=; b=VTKWyKECuXbJ14cIv0z+lM8OhOB9a e5uP/FoG21TXYewRAum0jEfoEA6vVncwMO4goesRfSN31IV/Rh+ZnI2mCimkunDr uV7eaaIpFlb6zWTPcjdPbkw9tRPRWOXGoJ2oR8Y/+A0DS5nseo9FluU8oaCbY9us ML6HbT/6xkGt+6YtzHPcN3oLBgWsbIug42tEIScHHjKYnXNBGFH58tZ1W0LqLh6r savTvf9DO9X0TcIL7JmIXyrletAY7YihJc9mjCM+9GhRTqQLj50H1VmlaO950YE1 C1STWq14YQIBkVbD6u0Y5pXinOdmyM0KwxTWq/fC01H6Rz9EJVdiin2/A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudelfedgjeeiucetufdoteggodetrfdotf 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 23:47:44 -0400 (EDT) Date: Mon, 25 Sep 2023 12:47:41 +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: <2f6f68343fcd244ef7be5dfae8e55f63@oss.nttdata.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PA7b0eEg0wqGviRY" Content-Disposition: inline In-Reply-To: <2f6f68343fcd244ef7be5dfae8e55f63@oss.nttdata.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --PA7b0eEg0wqGviRY Content-Type: multipart/mixed; boundary="l2HzZ57UGNURYJy4" Content-Disposition: inline --l2HzZ57UGNURYJy4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Sep 25, 2023 at 11:27:27AM +0900, Ryoga Yoshida wrote: > Thank you for the review. Certainly, adding a comments is a good idea. I > added a comment. Hmm. How about the attached version with some tweaks? -- Michael --l2HzZ57UGNURYJy4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0002-bug-fix-in-foce-within-pgstat_report_wal.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/ac= tivity/pgstat_wal.c index bcaed14d02..82feb792cf 100644 --- a/src/backend/utils/activity/pgstat_wal.c +++ b/src/backend/utils/activity/pgstat_wal.c @@ -38,13 +38,18 @@ static WalUsage prevWalUsage; * * Must be called by processes that generate WAL, that do not call * pgstat_report_stat(), like walwriter. + * + * force set to true ensures that the statistics are flushed; note that + * this needs to acquire the pgstat shmem LWLock, waiting on it. When + * set to false, the statistics may not be flushed if the lock could not + * be acquired. */ void pgstat_report_wal(bool force) { - pgstat_flush_wal(force); - - pgstat_flush_io(force); + /* like in pgstat.c, don't wait for lock acquisition when !force */ + pgstat_flush_wal(!force); + pgstat_flush_io(!force); } =20 /* --l2HzZ57UGNURYJy4-- --PA7b0eEg0wqGviRY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmURAt0ACgkQnvQgOdby QH00nxAAnL8zbEwf67IiAtmYI/IiHTHMumtlIU1ARhiE0v+Gmr27YgcJPuduDQ4l QmpIUab+bodoturl2WadNu+lbCMBHZG0m3zGO0/E9kFzQ5585m14JmueI2Px5/ZS TzGVihVU06U41UPp93zHHtU2uCQi8mKIAaT678sApan86hTao9+hgH0xMZ/AAPd2 tB4KVtI3PL76v47Yu+pms4z12yNvoBP8yHwmaOg3oVKw/ujMF4OcuqJ8CfQ2KDBY rcq4NEwKUeIgh5KwQbCKaQMtekqhsOZ1OUuv56No7wMC5N6KDLOelJmyeAhraEcc G5BoxCHpEf++Obj2JwWgkSzjPG1UTo1gVdG0AjFHeH6VneEB6S1F/+ItMAGq+Y00 gUUIWc2gjd4UVf4AktH6TQX9UFDLAK1Gs1+MgndkDwtzRckke6oTjsxLiwmZjlcx 0/YwRDvQNDfZi3UNUX4CAOJqs3uvDqG11w+B+XKosMKWCdmWX4dXcETCzlI6fICv 5aJeJjZ48IP1CBPoXwSsA39YQNyGN3hc81/7umrlewDfd2BYK2DppMAIrhF5qVSP GUKEW26IMrLRZPr7E2vXz9tCwDv4iHpZEBNaho6FNHtB7RM3igdMwgllRrQTCLsC c6/RV8nB0Jdi2Anyb6Fd7xLQ7Cnw4YK32QaxJYw74m9d+ai3Ze8= =g7/6 -----END PGP SIGNATURE----- --PA7b0eEg0wqGviRY--