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(data-modeling): stop remote clickhouse eof counting as a strike (#121149)

Jovan Sakovic72f4a90d0c7c
diff --git a/posthog/temporal/data_modeling/activities/utils.py b/posthog/temporal/data_modeling/activities/utils.py
index a5bb259bf6a0..db747951918b 100644
--- a/posthog/temporal/data_modeling/activities/utils.py
+++ b/posthog/temporal/data_modeling/activities/utils.py
@@ -94,6 +94,10 @@ def starts_a_failure_streak(saved_query_id: UUID, current_job: DataModelingJob)
# NOT "was this our fault" - a query that exhausts memory is one we do want suspended.
EXTERNALLY_ABORTED_MARKERS = (
"Code: 202", # TOO_MANY_SIMULTANEOUS_QUERIES
+ # ATTEMPT_TO_READ_AFTER_EOF from a remote shard that dropped the connection mid-query. The same
+ # code also covers a parse that runs out of input, which is the query's fault, so match the
+ # receive context and not the code.
+ "Attempt to read after eof: while receiving packet from",
"Cannot connect to host",
"Connection refused",
# our own egress proxy was unreachable, so nothing left the cluster - the trailing colon keeps a
diff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
index afcb4ab2a7ae..b8568079d589 100644
--- a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py
@@ -805,6 +805,8 @@ class TestNodeSuspension:
"aborted_error",
[
"Code: 202. DB::Exception: Too many simultaneous queries",
+ "ClickHouseError: Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from "
+ "ch-offline.example.com:9440: While executing Remote. (ATTEMPT_TO_READ_AFTER_EOF)",
"Cannot connect to host ch-offline.example.com:8443",
'ProxyConnectionError: Failed to connect to proxy URL: "http://proxy.example.com:3128/"',
"Abandoned: the materialization workflow is no longer running",
@@ -892,14 +894,16 @@ class TestNodeSuspension:
await database_sync_to_async(job.delete)()
@pytest.mark.parametrize(
- "memory_error",
+ "query_error",
[
"ClickHouseMemoryLimitExceededError: Code: 241. DB::Exception: Memory limit (for query) exceeded",
"ClickHouseMemoryLimitExceededError: Code: 241. DB::Exception: (total) memory limit exceeded",
"ClickHouseMemoryLimitExceededError: Code: 241. DB::Exception: Query memory limit exceeded",
+ "ClickHouseError: Code: 32. DB::Exception: Cannot parse Int64 from String, because value is too short. "
+ "(ATTEMPT_TO_READ_AFTER_EOF)",
],
)
- async def test_suspends_when_the_query_exhausts_memory(self, ateam, anode, asaved_query, adag, memory_error):
+ async def test_suspends_when_the_query_itself_fails(self, ateam, anode, asaved_query, adag, query_error):
from posthog.temporal.data_modeling.activities.utils import (
CONSECUTIVE_FAILURES_TO_SUSPEND,
is_node_suspended,
@@ -907,7 +911,7 @@ class TestNodeSuspension:
)
jobs = [
- await _make_job(ateam, asaved_query, DataModelingJob.Status.FAILED, error=memory_error)
+ await _make_job(ateam, asaved_query, DataModelingJob.Status.FAILED, error=query_error)
for _ in range(CONSECUTIVE_FAILURES_TO_SUSPEND)
]
@@ -917,7 +921,7 @@ class TestNodeSuspension:
dag_id=str(adag.id),
saved_query_id=asaved_query.id,
engine=DataModelingJobEngine.CLICKHOUSE,
- reason=memory_error,
+ reason=query_error,
job_id=str(jobs[-1].id),
)