Re: pgstat: allow a stats kind to use its own dedicated dsa/dshash

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgstat: allow a stats kind to use its own dedicated dsa/dshash
Date: 2026-10-18 07:00:00
Message-ID: d77717b5-8d7e-4a10-bb74-dc876e88d37f@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Jadhav 2026-10-18 07:35:05 Re: [PATCH] Fix recovery connection detail in EXEC_BACKEND builds
Previous Message Michael Paquier 2026-10-18 06:00:47 Re: pgstat: allow a stats kind to use its own dedicated dsa/dshash