Re: Add connection active, idle time to pg_stat_activity
Sergey Dudoladov <sergey.dudoladov@gmail.com>
From: Sergey Dudoladov <sergey.dudoladov@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Julien Rouhaud <rjuju123@gmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Kuntal Ghosh <kuntalghosh.2007@gmail.com>,
Rafia Sabih <rafia.pghackers@gmail.com>
Date: 2022-01-31T14:11:56Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove unstable pg_amcheck tests.
- cd3f429d9565 15.0 cited
Attachments
- v7_add_idle_active_time.patch (text/x-patch) patch v7
Hi,
Thank you for the reviews.
> > The write operation to beentry needs to be enclosed by
> > PGSTAT_BEGIN/END_WRITE_ACTIVITY(). In that perspective, it would be
> > better to move that writes to the PGSTAT_WRITE_ACTIVITY section just
> > below.
I have fixed it in the new version.
> > if (beentry->st_state == STATE_RUNNING ||
> > beentry->st_state == STATE_FASTPATH)
> > - pgstat_count_conn_active_time((PgStat_Counter) secs * 1000000 + usecs);
> > + {
> > + pgstat_count_conn_active_time((PgStat_Counter) usecs_diff);
> > + beentry->st_total_active_time += usecs_diff;
> > + }
> >
> > The two lines operates exactly the same way on variables with slightly
> > different behavior. pgStatActiveTime is reported at transaction end
> > and reset at every tabstat reporting. st_total_active_time is reported
> > immediately and reset at session end. Since we do the latter, the
> > first can be omitted by remembering the last values for the local
> > variables at every reporting. This needs additional two exporting
>
> Of course it's typo(?) of "values of the shared variables".
Could you please elaborate on this idea ?
So we have pgStatActiveTime and pgStatIdleInTransactionTime ultimately
used to report respective metrics in pg_stat_database.
Now beentry's st_total_active_time / st_total_transaction_idle_time
duplicates this info, so one may get rid of pgStat*Time counters. Is
the idea to report instead of them at every tabstat reporting the
difference between the last memorized value of st_total_*_time and
its current value ?
> > This needs additional two exporting
> > function in pgstatfuncs like pgstat_get_my_queryid so others might
> > think differently.
What would be example functions to look at ?
Regards,
Sergey