Skip to content

Commit 27c3205

Browse files
committed
fix(clickhouse): add execution time cap to task run metrics queries
`getTaskActivity` and `getAverageDurations` were registered without any `clickhouseSettings`, so neither had a server-side `max_execution_time`. Their sibling `existsQueryBuilder` in the same object literal already passes one. With no server cap, the only thing bounding a slow query is the client's `request_timeout`. That aborts the HTTP request rather than the query, so the failure surfaces as an untyped socket timeout instead of a ClickHouse timeout error, and stopping the query itself depends on the server noticing the disconnect. Set `max_execution_time: 25` on both. `@clickhouse/client` defaults `request_timeout` to 30000ms and nothing in this repo overrides it, so 25s sits below the client timeout — ClickHouse terminates the query and returns a typed error before the client gives up. Mirroring the neighbouring `10` would instead start failing queries that currently succeed in the 10-30s range. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PtQ34usZSzrSALPVBmoLYA
1 parent be45cf9 commit 27c3205

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Task metrics that take too long to load now stop with a clear error instead of hanging until the request gives up

internal-packages/clickhouse/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,16 @@ export class ClickHouse {
232232
existsQueryBuilder: getTaskRunExistsQueryBuilder(this.reader, { max_execution_time: 10 }),
233233
tagQueryBuilder: getTaskRunTagsQueryBuilder(this.reader),
234234
pendingVersionIdsQueryBuilder: getPendingVersionIdsQueryBuilder(this.reader),
235-
getTaskActivity: getTaskActivityQueryBuilder(this.reader),
235+
// Cap these server-side. The client's `request_timeout` defaults to 30s, and
236+
// without a `max_execution_time` that timeout is the only thing that stops a
237+
// slow query — it aborts the HTTP request rather than the query, so the
238+
// failure arrives as an untyped socket timeout. 25s keeps every query that
239+
// currently succeeds while letting ClickHouse terminate its own work first
240+
// and return a proper timeout error.
241+
getTaskActivity: getTaskActivityQueryBuilder(this.reader, { max_execution_time: 25 }),
236242
getCurrentRunningStats: getCurrentRunningStats(this.reader),
237243
getChildRunStatusCounts: getChildRunStatusCounts(this.reader),
238-
getAverageDurations: getAverageDurations(this.reader),
244+
getAverageDurations: getAverageDurations(this.reader, { max_execution_time: 25 }),
239245
getTaskUsageByOrganization: getTaskUsageByOrganization(this.reader),
240246
};
241247
}

0 commit comments

Comments
 (0)