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 1tqQTa-004mpq-Tk for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 05:42:27 +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 1tqQTY-006n2d-Gv for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 05:42:24 +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 1tqQTX-006muL-LW for pgsql-hackers@lists.postgresql.org; Fri, 07 Mar 2025 05:42:24 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tqQTV-001RMG-2K for pgsql-hackers@lists.postgresql.org; Fri, 07 Mar 2025 05:42:22 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8483D11400FE; Fri, 7 Mar 2025 00:42:20 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 07 Mar 2025 00:42:20 -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=1741326140; x=1741412540; bh=tbwEOAB035 31E1MX/kfjB5gX+oSVvbCMNSrGKezu+VQ=; b=NYNRUEkUVchyVzFuJcasmF1j1L QiFVDFFD4txbeFw8tghAcV9AxszBFpxIbC5CvYcbnR2bpP2KwvxI0ZchjlQPRGPW NP41e0uz6pGmWhX8oGlcqp9iTAg9UqU8H8TM8/7mB9g8xcH4SK1niMYlV6i+Cu23 ukNAWQ28kmowvFu9KIedsaVUwkCqbx9fLXoXEbkjrKWbe/ah4M1SYKMqy4CV8sWL 2cv9ottzP0lJCTO6kEbuBPMJwCM41+KNnorSHEsxkB8znHyq5j46WefjCZdZTPtF ZcGi9AaW1Z/acmuWuKa7JLrm44leISg6SqqSG/z5h9ArN93wRUTMoCXcZIew== 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= 1741326140; x=1741412540; bh=tbwEOAB03531E1MX/kfjB5gX+oSVvbCMNSr GKezu+VQ=; b=IdDyaVREskLOH2vaQEfd5vM29nNjOrqkmGRxfh2wVQ8rReKbYDk ALJ1Z7kUyRZvV0ASdqk9JWB3ygGl9lSgYJZhTeFPPbHdiWZgRwIyzAAa/Nbv8GqR BAU6fxCQccRKXF3Nh7ue8knn8NXmZT1aTdfOIMjoks9nugcr0fsH/5fM0EIy13Ed ZIzg9CjzIT4ditbImfICgaMEBWOvNguHjMchXNOFo7AyXc1IIKzDakKD7/36CfTK oPUSbLWxu1qu3jTkUKN++b7KE99pEqfRr3Z2Hg+6ZrGMAneLAY4bj+VkcK5MdF/r kzcr65BBhZ4ctKU9uXp2PL59gGuC4MXyoHw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdelkeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefu kfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivg hruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhep teelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggv lhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtph houhhtpdhrtghpthhtohepsggvrhhtrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhl rdgtohhmpdhrtghpthhtoheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpth htohepgihunhgvnhhgiihhohhusehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhq lhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Mar 2025 00:42:17 -0500 (EST) Date: Fri, 7 Mar 2025 14:42:13 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Andres Freund , Xuneng Zhou , pgsql-hackers@lists.postgresql.org Subject: Re: per backend WAL statistics Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M7zdMeQ771itEvJ7" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --M7zdMeQ771itEvJ7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 06, 2025 at 10:33:52AM +0000, Bertrand Drouvot wrote: > Indeed, there is no reason for pgstat_backend_have_pending_cb() to return= true if=20 > pgstat_tracks_backend_bktype() is not satisfied. >=20 > So it deserves a dedicated patch to fix this already existing issue: > 0001 attached. pgstat_backend_have_pending_cb(void) { - return (!pg_memory_is_all_zeros(&PendingBackendStats, - sizeof(struct PgStat_BackendPending))); + if (!pgstat_tracks_backend_bktype(MyBackendType)) + return false; + else + return (!pg_memory_is_all_zeros(&PendingBackendStats, + sizeof(struct PgStat_BackendPendin= g))); So, if I understand your point correctly, it is not a problem on HEAD because we are never going to update PendingBackendStats in the checkpointer as pgstat_count_backend_io_op[_time]() blocks any attempt to do so. However, it becomes a problem with the WAL portion patch because of the dependency to pgWalUsage which may be updated by the checkpointer and the pending callback would happily report true in this case. It would also become a problem if we add in backend stats a different portion that depends on something external. An extra check based on pgstat_tracks_backend_bktype() makes sense in pgstat_backend_have_pending_cb(), yes, forcing the hand of the stats reports to not do stupid things in a process where we should not report stats. Good catch from the sanity check in pgstat_report_stat(), even if this is only a problem once we begin to use something else than PendingBackendStats for the pending stats. This has also the merit of making pgstat_report_stat() do less work. -- Michael --M7zdMeQ771itEvJ7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmfKhzUACgkQnvQgOdby QH1fRQ/9GzjLRRufMCzRt4GltKk2Q4lC8fxsxsNHUPuqt6p4B7NRD3HWFlBiq83E OqxS3WKbO1QpgX7jPT9VQsGE3ncGZQbjf5wweI7BvR7zDAqt8UEHBBL5de/3A0fP htl5XoLseLXG/oj8MYc7H0QRBiKOngGRsPFDUD0ioZ3Ihj2PdBDnR8Buto9sIUdi TQ9UCxGFmlqLmAMIyC8BQ90Aua3ryfaqjCV561AER6gpnT397ZfHCyd0RWw7qBtJ VzQEFthgHtf2duBErbXcsALGukCwUFmF2Pal033icEsGFHNEvxMPmmHIRL+RlrID e5A9BMOBKw9PdAfkauuz6dQJEz5VwoOoVTQH3cXm69+k+7m3rz2KuZopKq7/ppba XTtXuun/a1CyD4EGFo72K82lZtY66/Wl3X2+KkxRuJXiktb+7IzRLE5Jtzd8ZEHJ xjCMJv7apsJjVmeX8Nz/KrrKxlJMdM9z2t1ZXLd5mMnc1r7i1WAaxq/jbdulECS4 plQTqXS4mSs4C6hej8i4GMO2flY7g0Hm2SWQ6n/CBe7bOoomvBa0ceD37XHoFlkL c9pD/riVwjw6N9paO847KINDCoUiutmzlWY43PaSrAwr9NO7Jtjs1eaWIfa//lP4 w2mx4I4cNdVbbwfOtfVBA0TqOJKUEsupg3vD9XJcxcJDD2G42gw= =zvU+ -----END PGP SIGNATURE----- --M7zdMeQ771itEvJ7--