Re: Add connection active, idle time to pg_stat_activity - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: Add connection active, idle time to pg_stat_activity
Date
Msg-id CAJ7c6TPY9Qjx720Wy3AFMtqH2POieOeB7Z=1gkb1wR5h2YcV8g@mail.gmail.com
Whole thread Raw
In response to Re: Add connection active, idle time to pg_stat_activity  (Sergey Dudoladov <sergey.dudoladov@gmail.com>)
Responses Re: Add connection active, idle time to pg_stat_activity
List pgsql-hackers
Rafia, Sergey,

Many thanks for working on this!

> I have incorporated most of the suggestions into the patch. I have also rebased and tested the patch on top of the
currentmaster
 

I noticed that this patch is marked as "Needs Review" and decided to
take a look.

I believe there is a bug in the implementation. Here is what I did:

```
57033 (master) =# select * from pg_stat_activity where pid = 57033;
...
total_active_time              | 9.128
total_idle_in_transaction_time | 0

57033 (master) =# select * from pg_stat_activity where pid = 57033;
...
total_active_time              | 10.626
total_idle_in_transaction_time | 0

57033 (master) =# BEGIN;
57033 (master) =# select * from pg_stat_activity where pid = 57033;
...
total_active_time              | 17.443
total_idle_in_transaction_time | 2314.703

57033 (master) =# select * from pg_stat_activity where pid = 57033;
...
total_active_time              | 2514.635
total_idle_in_transaction_time | 2314.703

57033 (master) =# COMMIT;
57033 (master) =# select * from pg_stat_activity where pid = 57033;
...
total_active_time              | 22.048
total_idle_in_transaction_time | 7300.911
```

So it looks like total_active_time tracks seconds when a user executes
single expressions and milliseconds when running a transaction. It
should always track milliseconds.

Please use `git format-patch` for the next patch and provide a commit
message, as it was previously pointed out by Bharath. Please specify
the list of the authors and reviewers and add a note about
incrementing the catalog version.

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: "ERROR: latch already owned" on gharial
Next
From: Aleksander Alekseev
Date:
Subject: Re: Add connection active, idle time to pg_stat_activity