Hi, On Wed, Sep 24, 2025 at 10:28:46AM -0400, Tom Lane wrote: > It seems plausible that the execution time of the stats > test's function-under-test is so short that it sometimes > doesn't register as more than zero on a machine with poor > clock resolution. It looks like that test only calls the > test function once or twice before checking that it's > accumulated some runtime, and the test function is nothing > more than > > CREATE FUNCTION test_stat_func() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN > END;$$; > > I'd call this a bug in that test TBH. It'd be saner to > make the function do something like pg_sleep for 1ms.
I did that in the attached, so far my Hurd VM ran the stats test more than 1000 times without a failure with it. I have the loop running till 10000, I'll report back tomorrow. Michael
>From d6a6995ea53695319dde1488e8f7f4b1bf8c21a8 Mon Sep 17 00:00:00 2001 From: Michael Banck <michael.ba...@credativ.de> Date: Wed, 24 Sep 2025 17:43:20 +0200 Subject: [PATCH] Add minimal sleep to stats isolation test functions. The functions test_stat_func() and test_stat_func2() had no function bodies. This made it possible that on machines with relatively low timer resolution the function would return before the clock advanced, making the test fail. To avoid that, pg_sleep for 1ms during the function. Per buildfarm members fruitcrow and hamerkop. --- src/test/isolation/specs/stats.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/isolation/specs/stats.spec b/src/test/isolation/specs/stats.spec index 1d98ac785b8..5b765da7eff 100644 --- a/src/test/isolation/specs/stats.spec +++ b/src/test/isolation/specs/stats.spec @@ -6,10 +6,10 @@ setup INSERT INTO test_stat_tab(key, value) VALUES('k0', 1); INSERT INTO test_stat_oid(name, oid) VALUES('test_stat_tab', 'test_stat_tab'::regclass); - CREATE FUNCTION test_stat_func() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$; + CREATE FUNCTION test_stat_func() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN PERFORM pg_sleep(0.001); END;$$; INSERT INTO test_stat_oid(name, oid) VALUES('test_stat_func', 'test_stat_func'::regproc); - CREATE FUNCTION test_stat_func2() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$; + CREATE FUNCTION test_stat_func2() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN PERFORM pg_sleep(0.001); END;$$; INSERT INTO test_stat_oid(name, oid) VALUES('test_stat_func2', 'test_stat_func2'::regproc); CREATE TABLE test_slru_stats(slru TEXT, stat TEXT, value INT); -- 2.39.5