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 1vl3Uw-006KKw-09 for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jan 2026 11:14:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vl3Uv-000wSg-0F for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jan 2026 11:14:09 +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.96) (envelope-from ) id 1vl3Uu-000wSU-1H for pgsql-hackers@lists.postgresql.org; Wed, 28 Jan 2026 11:14:09 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vl3Up-002iu0-37 for pgsql-hackers@lists.postgresql.org; Wed, 28 Jan 2026 11:14:07 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-4359a316d89so4987573f8f.0 for ; Wed, 28 Jan 2026 03:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769598843; x=1770203643; 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=Ih1wrzI8m7uImwQEvUfQeuMu+bGjEM7Iz+tewH3mzro=; b=J+YS7VV2fag0m433lLn50Q550S0K4E6rvUd4p+ZWaK387NT1jBQgm1HjF9st/NVC2+ 0EgqWwx0q9/t4UtFyNlA8HtNxosN9+fKqsimyEIV1LSijCuVOeDG0Um/F5qS81ppJ3j5 B6cvRH4YpItJQ2Xne1Jct6rALyK+kjbTB7EtTym1qVuvWEQSm65aMoWVApuZ0pI9f1pe XK0Opkkj3qeLJ80e88N8vhcFlG/F2IUHLtQ8fNCCKDGR8qlWsCGK0CMXWXy0egXMFSw6 HFh+eyBQ3QVYSwPQfYvTMnPL3Nge2OfVQTC94EsQgrnnYSCouVljzuGwoiHDWQDv+XmI pi+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769598843; x=1770203643; 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=Ih1wrzI8m7uImwQEvUfQeuMu+bGjEM7Iz+tewH3mzro=; b=uxixVKSsC3oDnbUvLwLsFb+01SfVyhgVsKEScjbt09IqKMredMZo+0UR5KdiclAbIG jMR7+E3e1ZuP/08BZeczWpTXBANQHoSsCQAVdIsnqpiSrkV661xxmzHjsjEpmzG2Vb9E pMNxlX19CPWURxj6dl+E3pjLIMHr+bl6fXY3gjtsFCUFJUDj5RsCXyWK0/P8pmMSQ0X8 wNJC+IX5aiFQBM2U02GWJuQKfJKYZHRRQVZ/31difVcj3wE80A5YEbqyCVkrpV+HOMXD WznDWrNJ/jhdhekH0GVA775FFSNAu5WaKFhUmI/qQO8T7qqanvokVQ/vTAB4jKZ5G8o0 wWyw== X-Forwarded-Encrypted: i=1; AJvYcCXV9mh1Ezq70QGvNhWos4afFTK2gD/c9R2f3uP0oV2DEwV6rgmkccNAgLiQkZ/06GizDCS82/smyup8X+/u@lists.postgresql.org X-Gm-Message-State: AOJu0Yz03oY9Oxxy3Y9Kl4FPLzgybafqcUQTENpv4gHuQ8a++sbVUSMd vcpcRNtKMQUKCy7I8OtTzczgHd4NP/y2wQDa6beXSk0W924SY8nQ3m3V X-Gm-Gg: AZuq6aIKs/nE5hvErv+YXE240+vYj/TMK2yvFuDFVQfGBhUMhzdT+QSZ2dD56wvn1dj cruTQCapRraoapu5rRDy6CNkB4D0ak2JBNm70kIniGjOsrz+Ht5wxAMFEsYhWgSpFa2+wruPuLP OZT0wm6GOEgwx1EGlqmkj4SY4i5jrpAuezbrdTmu5yzQqaT1+Igxqi3ectfnbO7i30lGRFO61pA c8O+FvZgAUdz+/1PXlFjvh2GUpICAzbNJDV0lHBElXEU+ryHNLLF+GjhddlGNirJX2r3fPm17zg 0cT0szRdldFWV4B/magWW5TcEwnqvQzXQYWHcIWfGPA5rTWEippyKbgBYJI+gXwi91OxXc9YvVy MuysIRmQW/ETqa4b8Te95VxFmqS5OlgS5TiiOo/rvLDC432M3oPwqQuhVXWK49otuIdcPa2FNU5 Zxz0WsGBkoFM8hvZCK94mGz3LT5ltuKrbc1CzGwfs5hWIgwZ3AllWrlCG97tq7EJqb73r7NGRhF wGB7id5NjqraDBO6PtF8ekgmjT8kZ/8gqsrepRIJH16Zx928DFFK61P X-Received: by 2002:a05:6000:4284:b0:430:fd69:9920 with SMTP id ffacd0b85a97d-435dd074adamr7017008f8f.16.1769598842928; Wed, 28 Jan 2026 03:14:02 -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-435e131cf4asm6362319f8f.28.2026.01.28.03.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 03:14:02 -0800 (PST) Date: Wed, 28 Jan 2026 11:14:00 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Fujii Masao , Sami Imseih , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Subject: Re: Flush some statistics within running transactions Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wR/mWGXukst4NraF" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --wR/mWGXukst4NraF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, Jan 28, 2026 at 03:35:21PM +0900, Michael Paquier wrote: > On Mon, Jan 26, 2026 at 06:59:28AM +0000, Bertrand Drouvot wrote: > > The attached, to apply on top of 0001, fix the issue. However it handles only the > > WaitLatch in ProcSleep() case and I start to have concern about the others WaitLatch() > > that would/could be "woken up" every 1s. > > > Using disable_timeout() and enable_timeout_after() in WaitEventSetWait() does not > > look like a great answer to this concern, so I wonder if we should use a larger > > flush frequency instead (as proposed up-thread), thoughts? > > Only a larger frequency is not the correct answer here. It would just > reduce the frequency of the extra lock wait messages for one: these > should never appear more than necessary. Right. The fix in fix_ProcSleep.txt shared up-thread solves that and has been added in 0001 attached. Also the attached is now split in 4 sub-patches with 0002 introducing a new GUC to control the flush interval (default is 10s). Note that 0001 to 0003 could be merged as one patch but I did it that way to ease the review. The new version also adds more documentation and takes care of Sami's comments shared up-thread. > And how about for example extension code? I think that depending on how they write their code around WaitLatch (if any) they could see messages being reported (if they do) in the logs at stats_flush_interval frequency. That said the default value is 10s and that looks pretty long for a latch to wait on. In any case, they should already take care of a latch being woken by WL_LATCH_SET. What do you think? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --wR/mWGXukst4NraF Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-Add-pgstat_report_anytime_stat-for-periodic-stats.patch"