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.96) (envelope-from ) id 1vustI-00BE1E-1J for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 13:55:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vustG-001DQX-06 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 13:55:54 +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.96) (envelope-from ) id 1vustF-001DQO-2O for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 13:55:53 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vustC-000000013uw-2M5G for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 13:55:53 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4837907f535so49745435e9.3 for ; Tue, 24 Feb 2026 05:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771941350; x=1772546150; 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=n2azYXltQ+CDKMlJSXW9LNPxlfyKfNfdFvTdbPv0Lg0=; b=EHc8j2OjAhUYfwqLfxIieBjI3QgpPQEKBymj05vFt2mhHhMK5A1O68gB8VcalJp8O5 AuRlkW8vzZlKiBJWLa1+3XenJF0/VixwXKw/VDmHTL1Y+tBINLN+7XxYOMijWwYUbsiR wmJl9+xUyPpg+iEr07Uo+ddKolOITk3q/EJfhnCeRiW5K6+Eljuc4y8AcvZL9l46nCgK IKWSebje1SYHnnrHjEqfNhgnbuji988wRci3XNtXEt/2AhkZclUGLUJSXfxlJOdMdZRj 0kRAdZvozXEpK5J0yB+1A0MwE1pDjho3WWVG8vaEzEufs32grQSSe1Q9YlQ8n++s83Q2 //Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771941350; x=1772546150; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n2azYXltQ+CDKMlJSXW9LNPxlfyKfNfdFvTdbPv0Lg0=; b=u6qJWoCbDy9a0yNQZezncSloypoh9alAhSljPreJIgnOu8NEjyv8nBh6Embo2hR5FH ancfhHEsFSkYsowv4mOposbPe2h7xpA0aBwsaZhpuuku4XJyu/PL6slGDTHmpAyyem6f MrovZEoijd+jJZbAMMHQ9yW149V53tRbJeldgVmjs7Z2LqOQ6gCSROVGP0Fwi8smNPI7 /+9dbhJ6Ne+Ic/4+Mb04kBnEszzA+6DOes8fC6ys7pJstGtgqmSJTQRLTC9tKZUJPABA TLFqbX62SqP/oeqf0ORjjN33clRTtcPyefXq6dEK8KOziA0863L+tsKKJq188tZius4+ foVQ== X-Forwarded-Encrypted: i=1; AJvYcCVXtfjcDfipojGDHiPAb2g8C9E0jI90eT3fGGGiO0wEFASo+9oERydhZgiLMztE9IHwF3HF50vrUh52QFmY@lists.postgresql.org X-Gm-Message-State: AOJu0YzyH7JhrFZsNQ4qb9RIW6wLB2IkgBHxOzlZ4ynB4zXDDWvURcsd 8FqNP1rC9izLF9/k3xuBqWQTea/XdORyXE5dsD4bj2xq/ODzF8FjIaL8 X-Gm-Gg: AZuq6aJ52pEcxWcth3DWl1M/HH9N/Kl73QVSYkW7HMY4OgDX9vvPEavntnxRJR91zxQ EvEAeIsVaGK1QqV/FmvdkT6ddGs96UDw9xVmrkLsqjF1kmYpp2hqROMDQGGoRoeUsg5d1MK+8Qk wLGwEZDOckfMTbibRRdP1eW5p0RFonw25UPMdLXYAPfcxdQfjXcxK0xTJHkvJQ+zxL3WIsdcnM8 XBbOazgjEN5hHVJvsfIM+HZWN5WfyTJG7MJFIwx5iKkVMXuy9oxtQTZfXxk7jm/ez7MFZVgZge0 Lh2AFdg22WBuzntDIABm+QgYLJbpY6cuPFuvHByv/GN4ZtxfoXP0h1BbBIpLQs5Lpjj0mil3nQO 4dBp1h2vJ4foRBpdq3BIkJjnTt4Y2YgDtfqKH8ckNjW21Uv75AFKb9rcGbKdICoijK3m1FJZDfy k3YJFqZwQq5ruvD4jBHnqjhrs0z+qRCjYH9i0Sd9VdeX8+Mgg6BuyDk/Vy/jgkHXFEFALCxLHyW Vkh2fvLFWXXPO+aQpvpVLuAD1yeS2phtBnsNvip2EF19yPwAERejVIllA== X-Received: by 2002:a05:600c:1386:b0:480:426e:9d38 with SMTP id 5b1f17b1804b1-483a960371amr199895435e9.27.1771941350211; Tue, 24 Feb 2026 05:55:50 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970d54754sm27293288f8f.36.2026.02.24.05.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 05:55:49 -0800 (PST) Date: Tue, 24 Feb 2026 13:55:48 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Sami Imseih , Fujii Masao , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Subject: Re: Flush some statistics within running transactions 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, Feb 24, 2026 at 08:48:31AM +0900, Michael Paquier wrote: > On Thu, Feb 19, 2026 at 08:01:36AM +0000, Bertrand Drouvot wrote: > > On Thu, Feb 19, 2026 at 12:58:12PM +0900, Michael Paquier wrote: > >> 2) The timeout requirement itself, relying on a timeout threshold > >> controlled by a backend-side configuration. > > > > What are you concerns with this? > > I am concerned about the three additional points/requirements: > 1) The need for all processes who want to flush non-transactional > stats to set up timeouts, unconditionally, which is what the patch > shows with the new InitializeTimeouts() calls added for example for > auxiliary processes. This forces the use of SIGALRM in these > processes, Right but they all already call pqsignal(SIGALRM, SIG_IGN), so I'm not sure to get the point. > This requires an extra unconditional RegisterTimeout(), as well. Yes, I'm not clear why that's an issue though. > 2) The need for all the stats to call pgstat_schedule_anytime_update() > in strategical places. This is less of a burden compared to 1), but > this leads to more complications in these code paths with the coding > requirements, especially for custom stats kinds. I think that's solved with Sami's proposal for variable stats kind (to flush or schedule when the session is idle). > 3) Enforcing a flush timeout unconditionally. What do you mean? It's done only if there is things to flush. > My main worries are mainly around 1), I guess, with the new SIGALRM > handler requirements for all auxiliary processes. Using a procsignal > path would allow us to rely on a solution that has the same > flexibility, combined with strategic additional flush calls that we > could spread depending on requirements we want to enforce in some > processes, like in the WAL sender, or perhaps the checkpointer. I see, but we know they'll have to flush IO or WAL stats at some point so enabling the timeout for those look ok. > The addition of the property to track if a > stats kind of OK to flush outside a transaction boundary is also > critical to have, of course. I am sold to the point point of the > design about this new property tracked in the stats kind meta-data. Great! > 039549d70f6 goes in line with the "client" prospective, where I would > like to think that strategic flush calls are more flexible. > > > Yeah, after our off-list discussion yesterday, I tried to implement the same > > trick that f1e251be80a has done with injection points (nice trick by the way!), > > but that led to: > > In this case, avoiding an injpoint allocation in a critical section > would be a two-step process: > - INJECTION_POINT_LOAD(), before the critical section, to warm up the > cache and do all the allocations. > - INJECTION_POINT_CACHED() with IS_INJECTION_POINT_ATTACHED() > (optional), to run the point, in the critical section. Oh okay, thanks for the explanation! Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com