Add Postmaster health monitoring statistics

From: Alaa Attya <alaa(dot)attya91(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Add Postmaster health monitoring statistics
Date: 2025-01-07 00:44:06
Message-ID: CAB_VXgs_b-hbCZbTgWWHp7Bro-e2+QnftbNv+q9bV6=Hgz30Vw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hello, this is a feature request that I wanted to discuss with you

*Problem:*

While PostgreSQL's postmaster manages all child processes, there's limited
visibility into its health metrics and process management statistics. This
information could be valuable for monitoring and debugging purposes.

*Metrics that we can track*

- The number of successful/failed processes spawns
- Child process lifecycle statistics
- Time taken for process initialization (initialization time for new
connections)
- Memory usage patterns
- Connection handling metrics

*Suggested approach*

Data structure

```
typedef struct PmStatData
{
pg_atomic_uint64 successful_spawns;
pg_atomic_uint64 failed_spawns;
pg_atomic_uint64 child_crashes;
pg_atomic_uint64 total_connect_time;
pg_atomic_uint64 num_connections;
TimestampTz start_time;
/* Add more metrics as needed */
} PmStatData;
```

1. we can initialize the statistic in "PostmasterMain"
2. then whenever we spawn a new child process we can update the metrics, we
can do this in this method "StartChildProcess"
3. then we can persist the results to a new table, maybe we can call it "
pg_postmaster_stats"

This idea came to mind when I wanted to trace the increase in memory usage
based on the fork of new postmaster processes.
also, it will enable users to have historical data about Postmaster spawns.
It will also help customers to get more info about the performance of new
connection handling.

Let me know if it makes sense to the Postgres community.
--
Regards,

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2025-01-07 01:03:05 Re: Fwd: Re: A new look at old NFS readdir() problems?
Previous Message Melanie Plageman 2025-01-07 00:12:53 Moving the vacuum GUCs' docs out of the Client Connection Defaults section