Skip to content

Commit

Permalink
fix: longRunningTransactionsAgeInSeconds
Browse files Browse the repository at this point in the history
- clock_timestamp will just return the current timestamp
- what we actually want to know is the lowest timestamp of the xact_start column

Signed-off-by: Roman Pertl <[email protected]>
  • Loading branch information
roock committed Nov 30, 2023
1 parent f5b613a commit 11c9972
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion collector/pg_long_running_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
longRunningTransactionsQuery = `
SELECT
COUNT(*) as transactions,
MAX(EXTRACT(EPOCH FROM clock_timestamp())) AS oldest_timestamp_seconds
MIN(EXTRACT(EPOCH FROM xact_start)) AS oldest_timestamp_seconds
FROM pg_catalog.pg_stat_activity
WHERE state is distinct from 'idle' AND query not like 'autovacuum:%'
`
Expand Down

0 comments on commit 11c9972

Please sign in to comment.