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 1tnB30-002slJ-TK for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2025 06:37: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 1tnB2z-00GnN6-Hp for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2025 06:37:33 +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 1tnB2y-00Gn3v-NF for pgsql-hackers@lists.postgresql.org; Wed, 26 Feb 2025 06:37:33 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tnB2v-0008mQ-20 for pgsql-hackers@lists.postgresql.org; Wed, 26 Feb 2025 06:37:31 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id AAA25114015B; Wed, 26 Feb 2025 01:37:29 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Wed, 26 Feb 2025 01:37:29 -0500 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:subject :subject:to:to; s=fm1; t=1740551849; x=1740638249; bh=XY5uyjXwkl OxvwsX67OALBTmCvdN17MiyG1ONGdyQ84=; b=TVmCyGXR0ggTUGQJi5T+Z9u/EK VCFwInuUugV/53nxtcNUEsf/bTdYSI4cBY1EgeUwnRmXLTUOmQ4ilG9fF69Xyti1 j+ALervj7Az2x47joluiIvpHpwiilyjk489dAFTew8C/y+c2caFTfHUh8X8WmZEm dNpQn7hb9HxBTYbgvb/omMxrYC9pYf62ei1Arb4Ltgu50nXugdNnJ3qJK3eQ2J5h ZYNh3WmA2w0GVV2YJA7sLBsXxxBpyW42+khRAci02e5tzD9kXeCNG8kvJOvQa312 Xgs5IpNFWQn7uWNUn0oY5ekGWMgOlyj38LD70827D1cl2GxyruAgdKEGWElA== 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:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1740551849; x=1740638249; bh=XY5uyjXwklOxvwsX67OALBTmCvdN17MiyG1 ONGdyQ84=; b=PKIh7oOViFQxTuLBjTlfcV2PKTrOPXNHWLtfPfDYuCoND3dUNmQ KYp2cTeDWbwJSrll70mnCW5cAntFoJ3yXVadAbbjh8HEaLeFiKU9eiVhkRXSvG1t 7ThuBVGDQK7rUwVsPfevV8nIXTmGwE4hl+bRoX5rmHWTGeeqG6U0HD1+88QHfUNz oNA8lKEe4evy44LUjSj+zmCJpPPEOLbjVTr1YNzSnRz2w7YSSJXW+sH/490DZKRa pOFhR23eWG0ZiF1DaBJ44DqLe6bMNG02u5xxuQruwb/kP9s9bh6fo2hFX1pkKEUU bpiqZgkQM0PTFTMwnq8ZcsHgiHsL+/zQWrA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekfeekjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculd ejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhep ofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighi iiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeffhfekueevteei gfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphht thhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurh houhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggt khgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Feb 2025 01:37:28 -0500 (EST) Date: Wed, 26 Feb 2025 15:37:10 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [BUG]: the walsender does not update its IO statistics until it exits Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qo3oKa0MXEQX4OaZ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --qo3oKa0MXEQX4OaZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 25, 2025 at 01:42:08PM +0000, Bertrand Drouvot wrote: > Now we can see that the numbers increased for the relation object and tha= t we > get non zeros numbers for the wal object too (which makes fully sense). >=20 > With the attached patch applied, we would get the same numbers already in > step 4. (means the stats are flushed without the need to wait for the wal= sender > to exit). @@ -2793,6 +2794,12 @@ WalSndLoop(WalSndSendDataCallback send_data) if (pq_flush_if_writable() !=3D 0) WalSndShutdown(); =20 + /* + * Report IO statistics + */ + pgstat_flush_io(false); + (void) pgstat_flush_backend(false, PGSTAT_BACKEND_FLUSH_IO); + /* If nothing remains to be sent right now ... */ if (WalSndCaughtUp && !pq_is_send_pending()) { That's bad, worse for a logical WAL sender, because it means that we have no idea what kind of I/O happens in this process until it exits, and logical WAL senders could loop forever, since v16 where we've begun tracking I/O. A non-forced periodic flush like you are proposing here sounds OK to me, but the position of the flush could be positioned better in the loop. If there is a SIGUSR2 (aka got_SIGUSR2 is true), WAL senders would shut down, so it seems rather pointless to do a flush just before exiting the process in WalSndDone(), no? I'd suggest to move the flush attempt closer to where we wait for some activity, just after WalSndKeepaliveIfNecessary(). -- Michael --qo3oKa0MXEQX4OaZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAme+tpYACgkQnvQgOdby QH0vPQ//fTykOI4AIJgDiyHx1dr87VIKrZ3spLIydQCxPAWG1HZ1RgqnLJZDVgk1 Mvf9ahL/aoXzYdndfhjebFHe8Mn9JLXgsdnQqcEvQgU4QmseO5nzAoPCFg2aBjab tuKwVw97XsubjDna0fNAqjjGo+YMZWr9YNugV2J9k2u7Wl8lA9Byn1VwdAf36YPc Sl8/3KSvdyr53GZs6ZUYl9uWYfK5VjOkKK+j/5NoISIPotxD+OJ90gO37y3nRrV9 yPk+DbUvkEOtkuVbBTUTHyCENB5+S015/B8Ck8dhjYY/WND+QkaKzWzFnY7PkO1X C7mjSneZx2r2KmvWJbKaHtVD1vZxtlSRvNGNJI4ITNhDBUpvhVrY2EaC1B3vjrwg kxqGCf02mMnALXcIQUr+WSaRJgtTOtrNIzzOQCsZailQRCHOEPsakqBrHYNTEkRB Fo6cVfzU7l6Bh6K5LWlnu+XQhnCjWYKoYy4W4Z8qI3hcjSzzvJ69kSHfpIcHskhO 1x35ZxkyWIEG+kADAdZOjnPQfHex1qeO+rchzAMScD2Q/1FGbrCZOXM0rKY1Yrwy 5g32DOTTc4Zv23oiP7z40hvAb00D0UWIOWxyUB9uAK2JhNodmC8wqu4IrHBEzrXA 2i5rdZHmTPuGccDEifoN66KosdeABo2P/UrYb0ScZQqXHSkBVxI= =ec25 -----END PGP SIGNATURE----- --qo3oKa0MXEQX4OaZ--