Skip to content

Commit 5e3acfc

Browse files
committed
fix: longRunningTransactionsAgeInSeconds
- clock_timestamp will just return the current timestamp - what we actually want to know is the lowest timestamp of the xact_start column
1 parent f5b613a commit 5e3acfc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: collector/pg_long_running_transactions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var (
5252
longRunningTransactionsQuery = `
5353
SELECT
5454
COUNT(*) as transactions,
55-
MAX(EXTRACT(EPOCH FROM clock_timestamp())) AS oldest_timestamp_seconds
55+
MIN(EXTRACT(EPOCH FROM xact_start)) AS oldest_timestamp_seconds
5656
FROM pg_catalog.pg_stat_activity
5757
WHERE state is distinct from 'idle' AND query not like 'autovacuum:%'
5858
`

0 commit comments

Comments
 (0)