// ClickHouse error reference

159: TIMEOUT_EXCEEDED (code 159)

The query or a waiting operation ran past max_execution_time or an internal timeout and was cancelled.

오류 코드
159
이름
TIMEOUT_EXCEEDED
카테고리
Resource limits
오류 메시지
Timeout exceeded: elapsed {seconds} seconds, maximum: {max_seconds}

의미

TIMEOUT_EXCEEDED (159) is raised when an operation exceeds a deadline. Most often the query went past max_execution_time. In replication contexts the same code appears when waiting on ZooKeeper or a quorum takes too long. The query is cancelled; over HTTP, rows already streamed to the client are not retracted and the exception follows them.

일반적인 원인

  • A scan-heavy query that genuinely needs more time than the limit allows.
  • A stuck distributed query waiting on an unresponsive shard.
  • Replication waits, quorum writes or ZooKeeper operations hitting their deadlines.

Find the cause

`system.query_log` elapsed time versus the limit for the query_id, `system.processes` for live queries and their elapsed time, `KILL QUERY WHERE query_id = '...'` to cancel a stuck one.

해결 방법

  1. Raise the limit for the heavy session only.

    SET max_execution_time = 300;
  2. Make the query cheaper: narrow columns, add a partition filter, or add LIMIT for exploratory reads.

    SELECT ts, value FROM events WHERE event_date >= today() - 1 LIMIT 1000;
  3. Make disconnecting HTTP clients cancel their reads: turn on cancel_http_readonly_queries_on_client_close in the server config; it is a server setting, not a session SET. Cap single requests instead with:

    SELECT uniq(number) FROM numbers(1000000) SETTINGS max_execution_time = 30;

Other ways to handle it

max_execution_time can be set per user profile instead of per session. For HTTP, max_execution_time in the URL parameters applies per request.

안전하게 재현하세요

The limit is checked as the query runs. sleep(3) with max_execution_time = 1 raises 159 at about 1 s, and uniq over a billion numbers at default block size finishes in under a second, so use a small max_block_size to force the check.

SET max_block_size = 1000 and max_execution_time = 1, then SELECT uniq(number) FROM numbers(1000000000); raises code 159 once a block finishes past the deadline.

질문

Does the query keep running server-side after the client times out?

For native clients with cancel on close and for 159 itself, the server cancels. An HTTP client disconnect alone may leave the query running unless cancel_http_readonly_queries_on_client_close is on.

Why did I get 159 on a replicated INSERT?

Quorum or ZooKeeper waits use the same code path; check replica health before raising timeouts.

관련 오류

More resource limits errors

코드와 메시지 텍스트의 출처는 다음과 같습니다 ClickHouse documentation (system.errors). 전체 목록은 ClickHouse error list 또는 모든 데이터베이스 오류 검색.

// 오류는 줄이고, 수정은 빠르게

Work on ClickHouse in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for ClickHouse and the other databases you use.

이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.