Skip to content

Commit 3d6c2d8

Browse files
valvesssclaude
andcommitted
fix(telemetry): FILTER must bind to the aggregate inside extract(), not outside
`extract(epoch from max(...)) filter (where ...)` is a syntax error — FILTER attaches to extract() (not an aggregate). Move it inside: extract(epoch from max(...) filter (where ...)). SAMPLE_SQL failed on every project's sampler tick. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f5c8dcf commit 3d6c2d8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

control-plane/src/telemetry/sampler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ select
2727
or state = 'idle in transaction (aborted)')::int as idle_in_tx,
2828
count(*) filter (where wait_event_type is not null and state = 'active')::int as waiting,
2929
count(*) filter (where wait_event_type = 'Lock')::int as blocked,
30-
coalesce(extract(epoch from max(now() - xact_start))
31-
filter (where state <> 'idle' and xact_start is not null), 0)::float as longest_tx_secs,
32-
coalesce(extract(epoch from max(now() - state_change))
33-
filter (where state = 'idle in transaction'), 0)::float as oldest_idle_in_tx_secs,
30+
coalesce(extract(epoch from max(now() - xact_start)
31+
filter (where state <> 'idle' and xact_start is not null)), 0)::float as longest_tx_secs,
32+
coalesce(extract(epoch from max(now() - state_change)
33+
filter (where state = 'idle in transaction')), 0)::float as oldest_idle_in_tx_secs,
3434
pg_database_size(current_database())::bigint as db_size
3535
from pg_stat_activity
3636
where datname = current_database()

0 commit comments

Comments
 (0)