Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jyothikirant-sayukth
Copy link

@jyothikirant-sayukth jyothikirant-sayukth commented Nov 14, 2024

To extract time in seconds for pg_long_running_transactions_oldest_timestamp_seconds query which currently returns epoch time.

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]>
Copy link

@alphabet5 alphabet5 left a 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.)

@alphabet5
Copy link

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?

@alphabet5
Copy link

I modified the query to exclude a few more things. idle was not matching idle in transaction queries, and there are a few other common long running queries that are not impactful. I'm not sure if this is useful for everyone though.

	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');
	`

@roock
Copy link

roock commented Dec 20, 2024

Would be great to have this fixes somewhen, I already reported it in April .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants