Re: Add connection active, idle time to pg_stat_activity
От | Rafia Sabih |
---|---|
Тема | Re: Add connection active, idle time to pg_stat_activity |
Дата | |
Msg-id | CA+FpmFf_fA6nNh94_i4xUMhL6t+ZnUWwqFRAJrp3AJua949CjA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Add connection active, idle time to pg_stat_activity (Dilip Kumar <dilipbalaut@gmail.com>) |
Ответы |
Re: Add connection active, idle time to pg_stat_activity
Re: Add connection active, idle time to pg_stat_activity |
Список | pgsql-hackers |
On Mon, 15 Nov 2021 at 12:40, Dilip Kumar <dilipbalaut@gmail.com> wrote: > > 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. Got it. Updated -- Regards, Rafia Sabih
Вложения
В списке pgsql-hackers по дате отправления: