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-warehouse): retry UNAVAILABLE rpc status in temporalio source (#73361)

Tom Owers42212057e553
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
index f4afec8cfa38..654d01b119d1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
@@ -59,13 +59,16 @@ T = TypeVar("T")
# Temporal Cloud surfaces transient server-side conditions as gRPC errors that a short backoff
# usually clears: per-namespace throttling (RESOURCE_EXHAUSTED — e.g. "namespace rate limit
-# exceeded") and request deadlines on the visibility/history services (DEADLINE_EXCEEDED — e.g.
-# "downstream duration timeout"). Riding these out in-process keeps a brief blip from failing the
-# whole import activity (which would rebuild the client and restart pagination) and avoids
-# error-tracking noise. Persistent failures re-raise so Temporal's activity retry still applies.
+# exceeded"), request deadlines on the visibility/history services (DEADLINE_EXCEEDED — e.g.
+# "downstream duration timeout"), and connection-level failures (UNAVAILABLE — e.g. a DNS lookup
+# blip resolving the cluster's frontend host). Riding these out in-process keeps a brief blip from
+# failing the whole import activity (which would rebuild the client and restart pagination) and
+# avoids error-tracking noise. Persistent failures re-raise so Temporal's activity retry still applies.
_MAX_TRANSIENT_RPC_ATTEMPTS = 6
-_RETRYABLE_RPC_STATUSES = frozenset({RPCStatusCode.RESOURCE_EXHAUSTED, RPCStatusCode.DEADLINE_EXCEEDED})
+_RETRYABLE_RPC_STATUSES = frozenset(
+ {RPCStatusCode.RESOURCE_EXHAUSTED, RPCStatusCode.DEADLINE_EXCEEDED, RPCStatusCode.UNAVAILABLE}
+)
# tonic/hyper surface a mid-stream HTTP/2 transport interruption (a reset stream or a response
# body read cut short) as an RPCError with status UNKNOWN and an "h2 protocol error" message,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py
index fb1e989fa4d1..629ac907683b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py
@@ -119,6 +119,9 @@ class TestTransientRPCRetry:
# tonic cancels a call that outruns the client's RPC deadline with status CANCELLED and
# message "Timeout expired" — a client-side timeout that must be ridden out, not raised.
("Timeout expired", RPCStatusCode.CANCELLED),
+ # A DNS resolution blip surfaces as UNAVAILABLE — a connection-level failure that must
+ # be ridden out rather than failing the whole import activity.
+ ("dns error", RPCStatusCode.UNAVAILABLE),
],
)
@patch(
@@ -146,6 +149,7 @@ class TestTransientRPCRetry:
[
("namespace rate limit exceeded", RPCStatusCode.RESOURCE_EXHAUSTED),
("downstream duration timeout", RPCStatusCode.DEADLINE_EXCEEDED),
+ ("dns error", RPCStatusCode.UNAVAILABLE),
],
)
@patch(