Re: Add connection active, idle time to pg_stat_activity

Поиск
Список
Период
Сортировка
От Dilip Kumar
Тема Re: Add connection active, idle time to pg_stat_activity
Дата
Msg-id CAFiTN-vG3QN+oO2VP0ui=vLGP8ofOtMQDYwG2P366XSdGbLMqg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add connection active, idle time to pg_stat_activity  (Rafia Sabih <rafia.pghackers@gmail.com>)
Ответы Re: Add connection active, idle time to pg_stat_activity  (Rafia Sabih <rafia.pghackers@gmail.com>)
Список pgsql-hackers
On Mon, Nov 15, 2021 at 4:46 PM Rafia Sabih <rafia.pghackers@gmail.com> wrote:
>
> On Mon, 15 Nov 2021 at 10:24, Dilip Kumar <dilipbalaut@gmail.com> wrote:
> >
> > On Wed, Nov 10, 2021 at 1:47 PM Rafia Sabih <rafia.pghackers@gmail.com> wrote:
> > >
> > > > It seems that in beentry->st_idle_time, you want to compute the
> > > > STATE_IDLE, but that state is not handled in the outer "if", that
> > > > means whenever it comes out of the
> > > > STATE_IDLE, it will not enter inside this if check.  You can run and
> > > > test, I am sure that with this patch the "idle_time" will always
> > > > remain 0.
> > > >
> > > Thank you Dilip for your time on this.
> > > And yes you are right in both your observations.
> > > Please find the attached patch for the updated version.
> >
> > Looks fine now except these variable names,
> >
> >  PgStat_Counter pgStatTransactionIdleTime = 0;
> > +PgStat_Counter pgStatTransactionIdleInTxnTime = 0;
> >
> > Now, pgStatTransactionIdleTime is collecting just the Idle time so
> > pgStatTransactionIdleTime should be renamed to "pgStatIdleTime" and
> > pgStatTransactionIdleInTxnTime should be renamed to
> > "pgStatTransactionIdleTime"
> >
> Good point!
> Done.

@@ -1018,7 +1019,7 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg,
TimestampTz now)
  pgLastSessionReportTime = now;
  tsmsg->m_session_time = (PgStat_Counter) secs * 1000000 + usecs;
  tsmsg->m_active_time = pgStatActiveTime;
- tsmsg->m_idle_in_xact_time = pgStatTransactionIdleTime;
+ tsmsg->m_idle_in_xact_time = pgStatIdleTime;

I think this change is wrong,  basically, "tsmsg->m_idle_in_xact_time"
is used for counting the database level idle in transaction count, you
can check "pg_stat_get_db_idle_in_transaction_time" function for that.
So "pgStatTransactionIdleTime" is the variable counting the idle in
transaction time, pgStatIdleTime is just counting the idle time
outside the transaction so if we make this change we are changing the
meaning of tsmsg->m_idle_in_xact_time.

-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Rafia Sabih
Дата:
Сообщение: Re: Add connection active, idle time to pg_stat_activity
Следующее
От: "osumi.takamichi@fujitsu.com"
Дата:
Сообщение: RE: Failed transaction statistics to measure the logical replication progress