1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Add pg_stat_database counters for sessions and session time

This add counters for number of sessions, the different kind of session
termination types, and timers for how much time is spent in active vs
idle in a database to pg_stat_database.

Internally this also renames the parameter "force" to disconnect. This
was the only use-case for the parameter before, so repurposing it to
this mroe narrow usecase makes things cleaner than inventing something
new.

Author: Laurenz Albe
Reviewed-By: Magnus Hagander, Soumyadeep Chakraborty, Masahiro Ikeda
Discussion: https://postgr.es/m/b07e1f9953701b90c66ed368656f2aef40cac4fb.camel@cybertec.at
This commit is contained in:
Magnus Hagander
2021-01-17 13:34:09 +01:00
parent 891a1d0bca
commit 960869da08
10 changed files with 405 additions and 6 deletions

View File

@ -2865,6 +2865,9 @@ die(SIGNAL_ARGS)
ProcDiePending = true;
}
/* for the statistics collector */
pgStatSessionEndCause = DISCONNECT_KILLED;
/* If we're still here, waken anything waiting on the process latch */
SetLatch(MyLatch);
@ -4579,9 +4582,15 @@ PostgresMain(int argc, char *argv[],
* means unexpected loss of frontend connection. Either way,
* perform normal shutdown.
*/
case 'X':
case EOF:
/* for the statistics collector */
pgStatSessionEndCause = DISCONNECT_CLIENT_EOF;
/* FALLTHROUGH */
case 'X':
/*
* Reset whereToSendOutput to prevent ereport from attempting
* to send any more messages to client.