Hello Sami, Tom, and Michael,

18.10.2026 05:46, Sami Imseih wrote:
To confirm, I tested by slowing down pgstat_shutdown_hook(), and I was
able to reproduce similar failures.

+++ b/src/backend/utils/activity/pgstat.c
@@ -658,6 +658,9 @@ pgstat_shutdown_hook(int code, Datum arg)
         if (OidIsValid(MyDatabaseId))
                 pgstat_report_disconnect(MyDatabaseId);

+       if (!dlist_is_empty(&pgStatPending))
+               pg_usleep(1000000L);
+
         pgstat_report_stat(true);

I tried check-world with the similar modification yesterday:
@@ -615,6 +615,7 @@ pgstat_shutdown_hook(int code, Datum arg)
     if (OidIsValid(MyDatabaseId))
         pgstat_report_disconnect(MyDatabaseId);

+pg_usleep(100000);
     pgstat_report_stat(true);

and discovered that many other tests can't survive this. Most of them fail
due to "sorry, too many clients already" and this can be fixed globally
by:
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -735 +735 @@ sub init
-               print $conf "max_wal_senders = 10\n";
+               print $conf "max_wal_senders = 30\n";
@@ -742 +742 @@ sub init
-               print $conf "max_connections = 10\n";
+               print $conf "max_connections = 30\n";

But there are also several tests that need extra care:
src/bin/pg_basebackup/t/030_pg_recvlogical.pl
src/test/modules/test_aio/t/004_read_stream.pl
src/test/modules/test_checksums/t/003_standby_restarts.pl
src/test/recovery/t/007_sync_rep.pl
src/test/recovery/t/040_standby_failover_slots_sync.pl
src/test/recovery/t/048_vacuum_horizon_floor.pl
contrib/test_decoding/t/001_repl_stats.pl
e.g.:
t/001_repl_stats.pl .. 3/?
#   Failed test 'stats file must exist after shutdown'
#   at t/001_repl_stats.pl line 177.
# Looks like you failed 1 test of 6.
contrib/test_decoding/tmp_check/log/001_repl_stats_test.log:TRAP: failed Assert("!ps->dropped"), File: "pgstat.c", Line: 1775, PID: 1057288


By the way, that sleep makes 001_custom_stats.pl fail even at 31280d96a
(which introduced the test on 2025-12-08).

Best regards,
Alexander

Reply via email to