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.

perf(lazy-precompute): stop retrying builds that hit the read byte cap (#68931)

Juraj Majerik67de56d6e99a
diff --git a/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py b/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
index 6e8867b51a09..f3770ce3053c 100644
--- a/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
+++ b/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
@@ -311,6 +311,11 @@ NON_RETRYABLE_CLICKHOUSE_ERROR_CODES = {
# Too many simultaneous queries means the cluster is overloaded.
# Rather than adding to the load with retries, surface the error.
202, # TOO_MANY_SIMULTANEOUS_QUERIES
+ # The rows/bytes-to-read cap is deterministic for a given window: the data
+ # won't shrink between attempts, so an immediate retry re-scans the same
+ # terabytes only to fail the same way. Fail fast so the caller can fall
+ # back or narrow the window.
+ 307, # TOO_MANY_ROWS_OR_BYTES
# An OOM won't succeed on an immediate retry with the same window — retrying just
# adds memory pressure to a cluster that already signaled it's out of memory. Fail
# fast so the caller can react (e.g. cap the team's window) and fall back.
diff --git a/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py b/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
index 3d8f567ea800..51652926660b 100644
--- a/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
+++ b/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
@@ -2650,6 +2650,9 @@ class TestIsNonRetryableError(BaseTest):
("no_such_column", 16, "No such column"),
("timeout", 159, "Timeout exceeded"),
("too_many_queries", 202, "Too many simultaneous queries"),
+ # The read cap is deterministic for a given window: a retry re-scans
+ # the same data only to fail the same way.
+ ("too_many_rows_or_bytes", 307, "Limit for rows or bytes to read exceeded"),
# An OOM won't succeed on an immediate retry — retrying just re-pressures the
# cluster. Fail fast so the caller can react (e.g. cap the team's window).
("memory_limit", 241, "Memory limit exceeded"),