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 1tDR66-000fvj-R7 for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 16:29:02 +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 1tDR65-00EaXB-FB for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 16:29:01 +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 1tDR65-00EaX3-52 for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 16:29:01 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDR62-002mHj-D4 for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 16:29:00 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-38231f84dccso886074f8f.1 for ; Tue, 19 Nov 2024 08:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732033737; x=1732638537; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EDL0qkKVEeInv8ojY4OM6WAVDFF7eeC28X8jFj5xSE4=; b=KcLezn/AGWUmgaBVKgT0q6NdVmTFSvpF46Qkk0A3hCNy6wmcLfVAwYASHh+eS4Vcrl hGuIQ9rNGPRwmIJq3NunsvHssyIBjTbtBT8qZijm7xUhSQnW4fkF5XhGk9Qi2GPFVRHr U45Tcgtud+hI1XjnGCFHGb1u3FU2jcYI/30Q8eKclNKVjfb1V7F1jsSegQX7cIvRzP0O jN04sZEmwyg3hBm1mk5z2exb9xP4p8Fncj2Ane75IjmSSaTcOmiyW4+s5iB6t4onKM64 cCeOoDTYuV2oS8tDu/VXMBZzi8eXabI+YSOixC+EE2gsgriyUSytLC7yciarNOfDjCSH vypA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732033737; x=1732638537; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EDL0qkKVEeInv8ojY4OM6WAVDFF7eeC28X8jFj5xSE4=; b=XirsH0rpdYLMHB9JCafm/ekmkAwOzqstKYGxT0mDBH8ES4I3At8RBY0n/Vui+Eho9i mRyb1nWJQyHaUw64rHm4ALIM5CSe7/+VRxlpu6xoKiBe3oJI/DdWJNNRfQK1osru6lr3 ua3EmzncYPpcuotOiakZr2jDlyRHMrcYbApkieFy7KEfn5lpq/QaWkaybYq4OaLouPHQ A0FJbUZdUJ4/rE1UvLDWIBUCmhkJ3pXyQ/qIFDzzvCJGhM7TtuAfsXtJHxafb1DVKKea nWOhJwZE1lrAButo1f90drw5zOHuCM+h72n1ZPc24LoqO+PFDMij1saSi+HUfsND3iMO N7vw== X-Forwarded-Encrypted: i=1; AJvYcCWr8gTNkRizfB9Fi8LVFADJDYT1Ytgn/hnHlvMGF5fsiqJkipkqbkZrF5IIxF1LhIZn2Yf0mreSb+h0EHol@lists.postgresql.org X-Gm-Message-State: AOJu0YzY0MyQjcwB/+0K4OJGKfGURotjcxQAyGYWENViYtrxasJ+cyRB azUmeTXVOiD9BKGWb+sU51g3OAllA9qxaMmMRoNXVePM3mlLmDQ4JK4RTw== X-Google-Smtp-Source: AGHT+IENdPiZsPXtuAntN7SHRMrLpu1+B4wsbfQovmkZ1iEtvj5J9vjfGDP6weiEvm8iNnbC+soc3g== X-Received: by 2002:a5d:6c6b:0:b0:37d:4fab:c198 with SMTP id ffacd0b85a97d-38225a29f42mr13203536f8f.26.1732033737104; Tue, 19 Nov 2024 08:28:57 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da2658a8sm206730915e9.9.2024.11.19.08.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 08:28:56 -0800 (PST) Date: Tue, 19 Nov 2024 16:28:55 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Nazir Bilal Yavuz , Alvaro Herrera , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: per backend I/O statistics Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Nov 19, 2024 at 10:47:53AM +0900, Michael Paquier wrote: > On Thu, Nov 14, 2024 at 01:30:11PM +0000, Bertrand Drouvot wrote: > > - change the arguments to false in the pgstat_drop_entry_internal() call in > > pgstat_drop_all_entries() > > - start the engine > > - kill -9 postgres > > - restart the engine > > > > You'll see the assert failing due to the startup process. I don't think it is > > doing something wrong though, just populating its backend stats. Do you have > > another view on it? > > It feels sad that we have to plug in the internals at this level for > this particular case. Perhaps there is something to do with more > callbacks. Or perhaps there is just no point in tracking the stats of > auxiliary processes because we already have this data in the existing > pg_stat_io already? We can not discard the "per backend" stats collection for auxiliary processes because those are the source for pg_stat_io too (once the 2 flush callbacks are merged). I have another idea: after a bit more of investigation it turns out that only the startup process is generating the failed assertion. So, for the startup process only, what about? - don't call pgstat_create_backend_stat() in pgstat_beinit()... - but call it in StartupXLOG() instead (after the stats are discarded or restored). That way we could get rid of the changes linked to the assertion and still handle the startup process particular case. Thoughts? > > How would that work for someone doing "select * from pg_stat_get_backend_io()"? > > > > Do you mean copy/paste part of the code from pg_stat_get_activity() into > > pg_stat_get_backend_io() to get the backend type? That sounds like an idea, > > I'll have a look at it. > > I was under the impression that we should keep PgStat_Backend for the > reset_timestamp part, but drop BackendType as it can be guessed from > pg_stat_activity itself. Removing BackendType sounds doable, I'll look at it. > >> Structurally, it may be cleaner to keep all the callbacks and the > >> backend-I/O specific logic into a separate file, perhaps > >> pgstat_io_backend.c or pgstat_backend_io? > > > > Yeah, I was wondering the same. What about pgstat_backend.c (that would contain > > only one "section" dedicated to IO currently)? > > pgstat_backend.c looks good to me. Could there be other stats than > just IO, actually? Perhaps not, just asking.. Yeah that's the reason why I suggested "pgstat_backend.c". I would not be surprised if we add more "per backend" stats (that are not I/O related) in the future as the main machinery would be there. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com