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.94.2) (envelope-from ) id 1uP69n-000F3q-14 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jun 2025 21:05:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uP69l-009mzO-0S for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jun 2025 21:05:17 +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.94.2) (envelope-from ) id 1uP69k-009mzG-Le for pgsql-hackers@lists.postgresql.org; Tue, 10 Jun 2025 21:05:17 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uP69j-001Ina-0i for pgsql-hackers@postgresql.org; Tue, 10 Jun 2025 21:05:16 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-451ebd3d149so38215245e9.2 for ; Tue, 10 Jun 2025 14:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749589513; x=1750194313; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :subject:cc:to:from:date:sender:message-id:from:to:cc:subject:date :message-id:reply-to; bh=n0vk0MOsDP9WXzEcYpISskHSY7NN5uaF7qFj0Dd5DMI=; b=nFP/+SwvST12dzJe6ls3IyXRrUBrIFg5cU+QFq90obtj6fbG8fsN4McwoP7hkA0v7e Z+YaBrqMcL63INomz8vy+G8pVXB44V1q3RG+F3d5iTB0AYegMGpQvrGRXVUzXevZYPVw 2dszLxVTB9Gy/me5evwfa2CnLvr3pQTyHPZQfP3UYrCvQD8SDpi8jmlpehAR8ozDwwDR fSfVGBuTB81SRCWVpEKmOYEmVWpsxHfbkSSTW/iMAXbklHlhzl4BmqbDJGXcBCqh25Xj 0FX9sDPeV+9eGMDT7+PRkFISdZZ8WTqVtrZPoiLJY/dQeWf+mMFefuRjtCxSTeQ1KtxP hH9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749589513; x=1750194313; h=user-agent:in-reply-to:content-disposition:mime-version:references :subject:cc:to:from:date:sender:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=n0vk0MOsDP9WXzEcYpISskHSY7NN5uaF7qFj0Dd5DMI=; b=uy0Ur/P8UnMaMdhzQ+DcySsa4ril5XLGbjVEEUfZaocNM7NHY72eAJcAg19+Ti9h5h xcjBv57OWh6IUM9j/xyeltPqFY2/8Rbg14CtSeQ+0t1qh+gbP4QLJCeVDRjB/6tKcOzC RtF5cJ/hvEE1CxIR0Fdww2pAgsTTzlAd7DvEdF0c07jJ9jQ7Sk+lYMVpga1b+rdZr18X pEtqte/ITlMwo8BBTdo968UW1+ekl1m4OgDNAx+9sD5g0E3r0yU0yHsTz2N00vgnwc90 c3B1I5X0XDXU8/m/HavAzcJYxocldcTI2f/8dlHqlsRAB06Q0hLrDRl2O2MC1P97OWg9 SFoA== X-Forwarded-Encrypted: i=1; AJvYcCUF6y7v/grvaTmsH+R3imghZ5JK7hCvmPXLwoR+5tC+N2dGtlMLn5LkM7gsRsT4SPyPamTM3Vbbf4WMN1vT@postgresql.org X-Gm-Message-State: AOJu0YwBzcOrvXLPCU9YyFUs8hVPKLcW9vUv8q73+dG9cA2I19MSQiPH h1QOhUd6iOwlo9+bT58T7azX/U8hxJUqU9vmtYvSiNEh+llwjCC9US7A X-Gm-Gg: ASbGnctg5PC5rvrx6SSVuT1Bkp9NIHC4r3DF6ZWJPfHB1wMrRGiy/xTGJaDcA74LE1R 7IfJvADu+9JL8azs1SBgAf/31hExRbHxHodjGAQnLdqUhILL7dq95jvO6IRaQd70lkHKCcWiJ4+ IeQLKj0giP2g0a2W+JlCahvAMgcvRGsdXSlF+pq4BZNwNK39NtB04RQrFFouNB2hSuDIJJb+LLk 0XzpNi0hPvpfX7FqqlM/J46c6PRV1jwXvyiTOr951yl+29IU+fNJw3z2aP8mDuTxnqV/nlav8K1 VmuV6hPeEhs5n2/WmE8Lo/DkQP+W1gGv6x0eu4Fi/Zh/2K0uCGorkpIHaJElbqRqLS7U/Ubh3Tl JDf3rdrVoHGNckhZd2Fe7+EjOzW7lKA== X-Google-Smtp-Source: AGHT+IHq3HElzB/J4yCYPFrOtXU6bZsO3suyNiCgnahRexjkz5HUCn916xrtT/Msq6i7c6WK+P1SjQ== X-Received: by 2002:a05:600c:3b93:b0:43d:97ea:2f4 with SMTP id 5b1f17b1804b1-45324881397mr4942725e9.12.1749589513201; Tue, 10 Jun 2025 14:05:13 -0700 (PDT) Received: from lightning.caipicrew.dd-dns.de ([2001:a61:aa3:d01:75c4:e686:37fd:e458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a53229e009sm13637419f8f.16.2025.06.10.14.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 14:05:12 -0700 (PDT) Message-ID: <68489e08.df0a0220.3c14af.fdc6@mx.google.com> X-Google-Original-Message-ID: <20250610210511.GD27427@caipicrew.dd-dns.de;lightning.caipicrew.dd-dns.de> Sender: Michael Banck Received: from mbanck by lightning.caipicrew.dd-dns.de with local (Exim 4.92) (envelope-from ) id 1uP69f-00024l-KG; Tue, 10 Jun 2025 23:05:11 +0200 Date: Tue, 10 Jun 2025 23:05:11 +0200 From: Michael Banck To: Thomas Munro Cc: Andres Freund , Tom Lane , Andrew Dunstan , Robert Haas , pgsql-hackers Subject: Re: Cleaning up historical portability baggage References: <3322724.1659586159@sss.pgh.pa.us> <295419.1659918447@sss.pgh.pa.us> <747620.1660002360@sss.pgh.pa.us> <6846e0c3.df0a0220.39ef9b.c60e@mx.google.com> <68481005.df0a0220.23c1b8.78ca@mx.google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline In-Reply-To: <68481005.df0a0220.23c1b8.78ca@mx.google.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Tue, Jun 10, 2025 at 12:59:16PM +0200, Michael Banck wrote: > On Tue, Jun 10, 2025 at 09:05:03AM +1200, Thomas Munro wrote: > > https://savannah.gnu.org/task/?7050 > > 3. make check nowadays succeeds the subscription test that it failed in > the log mentioned in the above task, but it still fails the stats test: I take that back, the subscription test is flakey, but less so than the stats test as it only has one of those stats_reset comparisons, compared to several for stats. So I am seeing failures there only every few test runs. The reason those tests fail is that the Debian 12 era [1] GNU Mach I am currently using has 10ms timer resolution, so some of those stats_reset calls in quick succession do not lead to different timestamps and the checks fail. There are several "SELECT pg_sleep(0.1);" calls in stats.sql already, so I wonder whether a few more would be acceptable, or at least using pg_sleep(0.01)? Using the attached, I no longer see regression failures, even after running it for 10+ times. The good news is maybe two-fold: 1. GNU Mach recently got better timer resolution and the version in Debian unstable got that backported [2], so going forward this should not be a problem anymore. I'll try upgrading my VM and see whether that helps without the patch. 2. The fact that nobody else complained about those new(er) timestamp- comparison additions appears to imply that there are no 100ms resolution machines we support anymore. So did we consider switching those pg_sleep(0.1) calls in stats.sql to pg_sleep(0.01) to save a bit of time? Michael [1] As hurd-i386 is not a release architecture, there is no Debian 12 release for it. But the Debian GNU/Hurd porters made their own release based on a snapshot of the hurd-i386 archive at time of the bookworm release. [2] https://salsa.debian.org/hurd-team/gnumach/-/blob/master/debian/patches/git-hpet?ref_type=heads --T4sUOijqQbZv57TR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Stabilize-stats_reset-based-tests-for-low-resolution.patch" From a0b71da960ada0f5f8927920486e8a7096ac975b Mon Sep 17 00:00:00 2001 From: Michael Banck Date: Tue, 10 Jun 2025 22:55:44 +0200 Subject: [PATCH] Stabilize stats_reset-based tests for low-resolution timers. On systems where the timestamp resolution is 10ms, two stats reset calls in quick sucession and the comparison of their timestamps might not lead to differences. Add 10ms pg_sleep() calls in order to ensure different timestamps on those systems. For the last_seq_scan timestamps tests we use 100ms pg_sleep() delays, which we could reconsider adjusting to 10ms as well giving nobody else complained about the stat reset tests without delay. --- src/test/regress/expected/stats.out | 18 ++++++++++++++++++ src/test/regress/expected/subscription.out | 6 ++++++ src/test/regress/sql/stats.sql | 3 +++ src/test/regress/sql/subscription.sql | 1 + 4 files changed, 28 insertions(+) diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out index 776f1ad0e53..803f4eac8ff 100644 --- a/src/test/regress/expected/stats.out +++ b/src/test/regress/expected/stats.out @@ -983,6 +983,12 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset -- Test that multiple SLRUs are reset when no specific SLRU provided to reset function +SELECT pg_sleep(0.01); -- assume a minimum timestamp granularity of 10ms + pg_sleep +---------- + +(1 row) + SELECT pg_stat_reset_slru(); pg_stat_reset_slru -------------------- @@ -1059,6 +1065,12 @@ SELECT stats_reset > :'recovery_prefetch_reset_ts'::timestamptz FROM pg_stat_rec -- Test that reset_shared with slru specified as the stats type works SELECT max(stats_reset) AS slru_reset_ts FROM pg_stat_slru \gset +SELECT pg_sleep(0.01); + pg_sleep +---------- + +(1 row) + SELECT pg_stat_reset_shared('slru'); pg_stat_reset_shared ---------------------- @@ -1098,6 +1110,12 @@ SELECT pg_stat_reset(); (1 row) SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset +SELECT pg_sleep(0.01); + pg_sleep +---------- + +(1 row) + SELECT pg_stat_reset(); pg_stat_reset --------------- diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 1443e1d9292..a2baa599769 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -61,6 +61,12 @@ SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscriptio -- Reset the stats again and check if the new reset_stats is updated. SELECT stats_reset as prev_stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' \gset +SELECT pg_sleep(0.01); -- assume a minimum timestamp granularity of 10ms + pg_sleep +---------- + +(1 row) + SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub'; pg_stat_reset_subscription_stats ---------------------------------- diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql index 232ab8db8fa..b78dc0c670d 100644 --- a/src/test/regress/sql/stats.sql +++ b/src/test/regress/sql/stats.sql @@ -467,6 +467,7 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset -- Test that multiple SLRUs are reset when no specific SLRU provided to reset function +SELECT pg_sleep(0.01); -- assume a minimum timestamp granularity of 10ms SELECT pg_stat_reset_slru(); SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp'; SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'notify'; @@ -493,6 +494,7 @@ SELECT stats_reset > :'recovery_prefetch_reset_ts'::timestamptz FROM pg_stat_rec -- Test that reset_shared with slru specified as the stats type works SELECT max(stats_reset) AS slru_reset_ts FROM pg_stat_slru \gset +SELECT pg_sleep(0.01); SELECT pg_stat_reset_shared('slru'); SELECT max(stats_reset) > :'slru_reset_ts'::timestamptz FROM pg_stat_slru; @@ -509,6 +511,7 @@ SELECT pg_stat_reset_shared('unknown'); -- Since pg_stat_database stats_reset starts out as NULL, reset it once first so we have something to compare it to SELECT pg_stat_reset(); SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset +SELECT pg_sleep(0.01); SELECT pg_stat_reset(); SELECT stats_reset > :'db_reset_ts'::timestamptz FROM pg_stat_database WHERE datname = (SELECT current_database()); diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 007c9e70374..d0ec8d18fa1 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -39,6 +39,7 @@ SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscriptio -- Reset the stats again and check if the new reset_stats is updated. SELECT stats_reset as prev_stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' \gset +SELECT pg_sleep(0.01); -- assume a minimum timestamp granularity of 10ms SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub'; SELECT :'prev_stats_reset' < stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub'; -- 2.39.5 --T4sUOijqQbZv57TR--