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 1vtCCy-008do7-2u for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 22:09:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vtCCw-005oCb-10 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 22:09:14 +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 1vtCCw-005oCT-05 for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 22:09:14 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vtCCt-00000000HU3-0ijH for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 22:09:13 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b9047e72201so208718666b.2 for ; Thu, 19 Feb 2026 14:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771538951; cv=none; d=google.com; s=arc-20240605; b=I23qoGshSziw9fso/ActFZ93EXw3A8PgWNLGDTNf7JaMseW2CaMj+tZpHirJDyTEex be6+FfT17hpOSxsW4XDNEYU5jBNE9uFWGk7Szfm+3SrGCYF/5cj1KWw1ocY3zwcp3+uJ 9YlVyQ0jLfFGUzkQp6Iv+tCwfoNe2ZzibnieXB9QXzm4JFNdGBj/s46PQp/J+vhohWeq Zx9sTWfy5Ve+IaRL/Z1nqWX7chDwbL1hrrd3y4ZTkihCZtaLyk2PpkvoQPMkkWTrJgTG mi/FDb1b/Gfx+2G2opa1lg8gZnSv2kP5FY4aCeRYy1f8GKjLNv23PXAUuQFt0XzMt3io j0yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=y4uTxbXwX+1r1j5QvKApQfZlgRLNbr8UbacHwDq83KI=; fh=lt9Pt8A6aCAXH/plprvDPnjWWRQ1vCwonzSnvcJZ52Q=; b=EeibmDJ2J7OxKafHah6v3W8TH2lXWtV2LVMh6Hu2HU3p6ADjXMUFe9dMgi6EPBDl61 OWHQLYqA43ld5mpQ+beldl4HsTgofReA+SlnWTbTxeuIKkpvUppZaV7dFXeGm7mJzYSI GStwdT/HKbjX3aFXkcvAD/mPy1Z/Tnfun39TV9zLx42RPoq/pEWkdrMp53T9ET2Vkc4m 5KaGXpQY/Ntyo0kVU45plrzgf/cvAC1p6WJxh01rdjOeB2ofGZlUSVmFykP4iLPc/+U3 kLirnjBZ1CyzjaNxjNiUt8jmO1eOUAz/xjLlsVmwGttzTGFnrvzAPXjpeNocmYn7spTA Cwpg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771538951; x=1772143751; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=y4uTxbXwX+1r1j5QvKApQfZlgRLNbr8UbacHwDq83KI=; b=PBOyJ8Ppi++sAjmySwfskC9fKUWoa/5pIRPaZsTkiE4zut8ysBqM+Bze1iR0sRktZv OQwhRL8bPt6TAV6Ws9Y7yayyEvCPC4XfAvuLu5z6xPptsgAg33C+7jX2BnrZGrmGiypS KM/sJnAyPj4sZgpemjXjs5IkGm2MDMR+aKvVuEr8rXB4pr7REBMryyyOGbNHRwMH8GU5 FlR46/PTLy69/VCEwrbywbT7CmysaW6i1l5ps7Ll5SdXPYJ+dBTW8mFUPdssMATlJHyR iZMLN37PjCwb2pSC4zLZvcRmPxV8/mF11bjJdU9FjNhSexBwUK8d8N5bIYd1aO/VO2wU 2MLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771538951; x=1772143751; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y4uTxbXwX+1r1j5QvKApQfZlgRLNbr8UbacHwDq83KI=; b=xEXPwd+lSX0TlxCzyQyxHTOzQNWglIe2WyoH/Y9KMjZm11ekOblDyDvGWpIuvAhVNn nUCuHpNJVCj0thWkjHF/R0VY7H8Nw2RTk+HPDEJDfx/Hy57jpYvMtjwHRkWAsuySbL18 iMq6cZb1h6zrTH9ZQfTZjxOWCmTh3uQ9EhGS5F9pZyIiEg33M8CQfOFPSAIsKsdmA3U+ RRhWAgYpezaHL0R/hCFczK9QSRE4ZWn0s5avZn+QIt+AhdfM1PwyqHbxvt7ViwQsy/hV c2/+Q/zmiG0HcXnreTuPoynq77AOr1cPKFigbOuzc+q/AGrlJJQbqXxhh0CNFtYKHHPe Z8Nw== X-Forwarded-Encrypted: i=1; AJvYcCUiPFVFq0R+fzoxamOSp02gIhOswa/yj/jgpmOos/o6DjSEr/wWlFuixzu9D8yOdulwuXyfjsb6MYFKmMgA@lists.postgresql.org X-Gm-Message-State: AOJu0Yx/GjCUApb8oAngqXYr27pI64QuX8JTf+dmHRChjnSG/o1kFdZ9 aTcG6aAgEtV8RnRnvL1Wbg5/o1rXPyZo/OCVwwJYGGXLsefIQ7zYqLbAul1Jyz+yOadnDslAQPZ D5DkycbSxQxQ+eo4egdstVbhbXr7Wozc= X-Gm-Gg: AZuq6aJBRE3tH0Zn0v+vFuip+10Ldz7rFXlQaIHm1CJQgdlZKOw1H957d7Eg+hH9WpE AUhSwTAr0tEDZhYmiDBloHDeReoSV8JuAOGRUWzniv4zepNcbrd+DW4wF+bk7N2d7oCKlp0NFr1 mMhXUHAD6t697PEWce/34hOWucnM86n5uscm1HfFF9mBakBFnl0nKPSdDOz9Wbwf88P3FK2B0rL fnVCgNytTn60oNoIRWAsC8JDuORDNjdsXCxubFNEQmqegHzK66wPc/sddyuszLjh+DYhzN9PEby BkRoSQ== X-Received: by 2002:a17:906:4fd3:b0:b90:47e6:e0ad with SMTP id a640c23a62f3a-b9047e6f34emr321539666b.56.1771538950553; Thu, 19 Feb 2026 14:09:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Thu, 19 Feb 2026 16:08:59 -0600 X-Gm-Features: AaiRm53BnMe1SAvTU03QbF8uILxgxfllLW2E-hiyA5FqgWzF_KYb9skv6FTi93A Message-ID: Subject: Re: Flush some statistics within running transactions To: Bertrand Drouvot Cc: Michael Paquier , Fujii Masao , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > Not a fan of the hardcoded sleeps in the tests, either. > > 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: > > TRAP: failed Assert("CritSectionCount == 0 || (context)->allowInCritSection"), File: "mcxt.c", Line: 1237 > postgres: main: walwriter (ExceptionalCondition+0x9e)[0xc4ce4d] > postgres: main: walwriter (MemoryContextAlloc+0x8c)[0xc8f0ec] > postgres: main: walwriter (MemoryContextStrdup+0x37)[0xc8fea1] > postgres: main: walwriter (pstrdup+0x22)[0xc8fee4] > postgres: main: walwriter (substitute_path_macro+0x65)[0xc56068] > postgres: main: walwriter [0xc55e90] > postgres: main: walwriter (load_external_function+0x59)[0xc553db] > postgres: main: walwriter [0xc7b858] > postgres: main: walwriter [0xc7c125] > postgres: main: walwriter (IsInjectionPointAttached+0x18)[0xc7c20c] > postgres: main: walwriter (pgstat_count_backend_io_op+0x12f)[0xa9a116] > postgres: main: walwriter (pgstat_count_io_op+0x169)[0xa9cb57] > postgres: main: walwriter (pgstat_count_io_op_time+0x1cc)[0xa9cda7] > > So, I did not spend that much time on it. I could if we strongly think that those > sleeps have to be discarded though. I took a look at this today out of interest, based on what you mentioned to me offline. There is this in injection_points.c ``` /* * Load an injection point into the local cache. * * This is useful to be able to load an injection point before running it, * especially if the injection point is called in a code path where memory * allocations cannot happen, like critical sections. */ void InjectionPointLoad(const char *name) { #ifdef USE_INJECTION_POINTS InjectionPointCacheRefresh(name); #else elog(ERROR, "Injection points are not supported by this build"); #endif } ``` so, instead of calling IS_INJECTION_POINT_ATTACHED macro which is called on-demand and in the case of I/O stats, during the critical section, you can just call INJECTION_POINT_LOAD during pgstat_initialize(), like this: ``` INJECTION_POINT_LOAD("anytime-update-reduce-timeout"); ``` Sami Imseih Amazon Web Services (AWS)