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(dags): retry NO_REPLICA_HAS_PART / NO_ACTIVE_REPLICAS in CH class… (#58338)

Bryan Ciaraldi14943be989c9
diff --git a/posthog/dags/common/resources.py b/posthog/dags/common/resources.py
index 96d4346b7f44..1ba157360370 100644
--- a/posthog/dags/common/resources.py
+++ b/posthog/dags/common/resources.py
@@ -42,6 +42,12 @@ def _is_retryable_clickhouse_exception(e: Exception) -> bool:
ErrorCodes.TOO_MANY_SIMULTANEOUS_QUERIES,
ErrorCodes.NOT_ENOUGH_SPACE,
ErrorCodes.SOCKET_TIMEOUT,
+ # Raised by waitMutationToFinishOnReplicas / cross-replica reads when the
+ # coordinator's snapshot of active replicas momentarily lacks the covering
+ # part (e.g. mid-fetch, mid-merge) or no replica is online. The mutation
+ # itself usually proceeds; the wait is what fails. Retry to re-poll.
+ ErrorCodes.NO_REPLICA_HAS_PART, # 234
+ ErrorCodes.NO_ACTIVE_REPLICAS, # 254
439, # CANNOT_SCHEDULE_TASK: "Cannot schedule a task: cannot allocate thread"
)
)