Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIZ7w-0004YY-Dv for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Aug 2022 17:22:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIZ7u-0004UF-Dp for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Aug 2022 17:22:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIZ7u-0004U5-5j for pgsql-bugs@lists.postgresql.org; Mon, 01 Aug 2022 17:22:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIZ7s-0005J3-4x for pgsql-bugs@lists.postgresql.org; Mon, 01 Aug 2022 17:22:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 271HMZWK1856494; Mon, 1 Aug 2022 13:22:36 -0400 From: Tom Lane To: Andres Freund cc: Laetitia Avrot , Peter Eisentraut , Japin Li , "David G. Johnston" , John Naylor , PostgreSQL mailing lists Subject: Re: Statistics updates is delayed when using `commit and chain` In-reply-to: <20220801171051.vxnit2t6soddaquh@awork3.anarazel.de> References: <20220801161256.ogcacmw6txiecvfb@awork3.anarazel.de> <1839632.1659371158@sss.pgh.pa.us> <20220801164004.kybukw4j3svgcv54@awork3.anarazel.de> <1845220.1659372203@sss.pgh.pa.us> <20220801171051.vxnit2t6soddaquh@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 01 Aug 2022 10:10:51 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1856492.1659374555.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 01 Aug 2022 13:22:35 -0400 Message-ID: <1856493.1659374555@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2022-08-01 12:43:23 -0400, Tom Lane wrote: >> Yeah. I think we'd need to get rid of the "bool force" argument >> of pgstat_report_stat, and instead have it manage things internally >> based on understanding whether the current process uses a reporting >> timeout timer or not (if not, always send the report right away). > It's not as simple as looking at the backend type, I think. We'd not wan= t to > enable a timer in the commit-and-chain context, even in a normal backend= - > there's no chance we'll go idle. No, but that's not the point. During CommitTransaction we should check to see if it's more than X amount of time since our last stats report, and if so send a new one. No timer interaction involved there. When we go idle, if not inside a transaction and a report needs to be sent, then compute the wait time till it should be sent and set a timer for that. > I wonder if it was the wrong call to use timers for IdleSessionTimeout, > IdleInTransactionSessionTimeout and pgstats. We always use nonblocking s= ocket > IO these days, so perhaps we should instead just compute a relevant time= out > for the WaitEventSetWait() call? Meh. I think that that would end up with duplicative logic and duplicative gettimeofday calls, unless your idea is to get rid of the timeout.c facilities altogether. regards, tom lane