diff options
author | Magnus Hagander <magnus@hagander.net> | 2021-01-17 13:34:09 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2021-01-17 13:52:31 +0100 |
commit | 960869da0803427d14335bba24393f414b476e2c (patch) | |
tree | c36a0991f757696e4d46c079055c1e926e4623f6 /src/backend/tcop/postgres.c | |
parent | 891a1d0bca262ca78564e0fea1eaa5ae544ea5ee (diff) | |
download | postgresql-960869da0803427d14335bba24393f414b476e2c.tar.gz postgresql-960869da0803427d14335bba24393f414b476e2c.zip |
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
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 28055680aad..8dab9fd5780 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -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. |