Add minimal sleep to stats isolation test functions.
authorTom Lane <[email protected]>
Thu, 25 Sep 2025 17:29:02 +0000 (13:29 -0400)
committerTom Lane <[email protected]>
Thu, 25 Sep 2025 17:29:37 +0000 (13:29 -0400)
commitef18eeeeaea7f64aadf198875670f9d6e56b52df
tree7dfbf824a41484d8344806715c11de5b5daf6121
parent694057d236b114f8c750b996b9ca5b8a07424650
Add minimal sleep to stats isolation test functions.

The functions test_stat_func() and test_stat_func2() had empty
function bodies, so that they took very little time to run.  This made
it possible that on machines with relatively low timer resolution the
functions could return before the clock advanced, making the test fail
(as seen on buildfarm members fruitcrow and hamerkop).

To avoid that, pg_sleep for 10us during the functions.  As far as we
can tell, all current hardware has clock resolution much less than
that.  (The current implementation of pg_sleep will round it up to
1ms anyway, but someday that might get improved.)

Author: Michael Banck <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/68d413a3.a70a0220[email protected]
Backpatch-through: 15
src/test/isolation/specs/stats.spec