-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update pg_long_running_transactions.go #1092
Update pg_long_running_transactions.go #1092
Conversation
To extract time in seconds for pg_long_running_transactions_oldest_timestamp_seconds query which currently return epoch time. Signed-off-by: Jyothi Kiran Thammana <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into the same issue, and had the same solution. This works as expected. (I'm not a maintainer, so I'm not sure what approving does, but LGTM.)
Tagging @Sticksman and @SuperQ because you guys worked on the original pr and I'm not really sure what the process is here. Is there anything I can do to help get this into a release? |
I modified the query to exclude a few more things. longRunningTransactionsQuery = `
SELECT
COUNT(*) as transactions,
MAX(EXTRACT(EPOCH FROM clock_timestamp() - pg_stat_activity.xact_start)) AS oldest_timestamp_seconds
FROM pg_catalog.pg_stat_activity
WHERE state NOT IN ('idle', 'idle in transaction')
AND query NOT LIKE 'autovacuum:%'
AND NOT (query ~* '^VACUUM( ANALYZE)?(?! FULL)')
AND pg_stat_activity.xact_start IS NOT NULL
AND NOT (query ~* '^REFRESH MATERIALIZED VIEW CONCURRENTLY')
AND NOT (query ~* '^BEGIN ISOLATION LEVEL READ UNCOMMITTED');
` |
Would be great to have this fixes somewhen, I already reported it in April . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that it's clear that the metric should be the time that the oldest transaction has been running or if it is supposed to be the timestamp (epoch) of the start of the oldest transaction. Either way it was previously always returning the current time from what I can tell which is not useful to anyone.
To extract time in seconds for pg_long_running_transactions_oldest_timestamp_seconds query which currently returns epoch time.