From 11c99722bed034b66044e48a1964cae0ea895db1 Mon Sep 17 00:00:00 2001 From: Roman Pertl Date: Thu, 30 Nov 2023 15:38:42 +0100 Subject: [PATCH] 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 Signed-off-by: Roman Pertl --- collector/pg_long_running_transactions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/pg_long_running_transactions.go b/collector/pg_long_running_transactions.go index ffd89d5f0..1f0b76f9e 100644 --- a/collector/pg_long_running_transactions.go +++ b/collector/pg_long_running_transactions.go @@ -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:%' `