Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(clickhouse): treat out-of-disk-space (243) as non-retryable (#65941)

Tom Owers0ebfc8694994
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
index b8c3526afcbb..013b9f8ec744 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
@@ -191,6 +191,14 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val
# Retrying just re-loads an already memory-pressured server, so stop
# and tell them to act.
"Code: 241": "Your ClickHouse server ran out of memory while we were reading a table. This usually means the database is too small for the table being synced. Try scaling up your ClickHouse service (or raising its memory limit), or sync a smaller table or use an incremental sync, then resume.",
+ # NOT_ENOUGH_SPACE — the source ClickHouse server couldn't reserve
+ # disk space for a temporary file while running our extraction query
+ # (spilling a sort or buffering query output to disk). Its local disk
+ # / filesystem cache is full and can't evict enough to continue. Like
+ # Code: 241 this is a capacity problem on the customer's database, not
+ # something we can change our side, so retrying just re-loads an
+ # already disk-pressured server.
+ "Code: 243": "Your ClickHouse server ran out of disk space while we were reading a table (it couldn't reserve space for a temporary file). Try scaling up your ClickHouse service or freeing disk space, or sync a smaller table or use an incremental sync, then resume.",
# Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. `Int32` → `Int64`) after
# the destination table was created with the narrower type. Delta Lake can't widen
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
index 6a5e0ceeb7c6..8638abb3f198 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
@@ -631,6 +631,11 @@ class TestClickHouseSourceNonRetryableErrors:
# MEMORY_LIMIT_EXCEEDED (code 241) — per-query `max_memory_usage` budget
"Code: 241. DB::Exception: Query memory limit exceeded: would use 3.73 GiB "
"(attempt to allocate chunk of 4.60 MiB), maximum: 3.73 GiB. (MEMORY_LIMIT_EXCEEDED)",
+ # NOT_ENOUGH_SPACE (code 243) — source server couldn't reserve disk for a
+ # temporary file (filesystem cache full while buffering query output to disk).
+ "HTTPDriver for https://host:8443 received ClickHouse error code 243\n Code: 243. "
+ "DB::Exception: Failed to reserve 1048576 bytes for temporary file: reason cannot evict "
+ "enough space: While executing BufferingToFileSink. (NOT_ENOUGH_SPACE)",
# Source table no longer exists at sync time — dropped/renamed, or a materialized
# view's `.inner_id.<uuid>` inner table whose UUID changed when the view was recreated.
"Table soax_stage..inner_id.8c612ff0-b72c-4b20-8ea5-405ed002c2f6 not found or has no columns",