Re: Add session statistics to pg_stat_database

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Ahsan Hadi <ahsan(dot)hadi(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Soumyadeep Chakraborty <soumyadeep2007(at)gmail(dot)com>, Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add session statistics to pg_stat_database
Date: 2020-12-05 12:04:13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2020-12-04 at 16:55 +0100, I wrote:
> > > Basically, that would change pgStatSessionDisconnectedNormally into instead being an
> > > enum of reasons, which could be normal disconnect, abnormal disconnect and admin.
> > > And we'd track all those three as separate numbers in the stats file, meaning we could
> > > then calculate the crash by subtracting all three from the total number of sessions?
> >
> > I think at least "closed by admin" might be interesting; I'll have a look.
> > I don't think we have to specifically count "closed by normal disconnect", because
> > that should be the rule and could be more or less deduced from the other numbers
> > (with the uncertainty mentioned above).
> I am considering the cases
> 1) client just went away (currently "aborted")
> 2) death by FATAL error
> 3) killed by the administrator (or shutdown)

I think I figured it out. Here is a patch along these lines.

I named the three counters "sessions_client_eof", "sessions_fatal" and
"sessions_killed", but I am not wedded to these bike shed colors.

Laurenz Albe

Attachment Content-Type Size
0001-Add-session-statistics-to-pg_stat_database.v8.patch text/x-patch 22.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-12-05 12:54:33 Re: Proposed patch for key managment
Previous Message Amit Kapila 2020-12-05 10:59:07 Re: Parallel Inserts in CREATE TABLE AS