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-imports): retry a transient Temporal connect failure in post-load triggers (#93440)

Tom Owersaf5e69d1f2be
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
index 3b7eefbf5b0a..b35d94bea9fa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
@@ -537,7 +537,13 @@ def _is_retryable_temporal_rpc_error(exc: BaseException) -> bool:
# `workflow.start_child_workflow` they get none of the server-side retry a durable
# workflow command would have — a bare client RPC timeout would otherwise drop the
# trigger permanently.
- return isinstance(exc, RPCError) and exc.status in (RPCStatusCode.DEADLINE_EXCEEDED, RPCStatusCode.UNAVAILABLE)
+ if isinstance(exc, RPCError) and exc.status in (RPCStatusCode.DEADLINE_EXCEEDED, RPCStatusCode.UNAVAILABLE):
+ return True
+
+ # `async_connect()` runs before any service client exists, so a transient failure to
+ # reach the Temporal frontend (DNS blip, connection refused/reset) surfaces as the Rust
+ # bridge's untyped RuntimeError rather than an RPCError — treat it the same way.
+ return isinstance(exc, RuntimeError) and str(exc).startswith("Failed client connect:")
def _trigger_ducklake_register_data_imports(export_signal: ExportSignalMessage, prepared_queryable_folder: str) -> None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/test_processor.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/test_processor.py
index a1cbcb67ace0..f3c54625637c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/test_processor.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/test_processor.py
@@ -663,6 +663,25 @@ class TestPostImportTrigger:
assert client.start_workflow.call_count == 2
mock_capture.assert_not_called()
+ @patch(f"{_PROCESSOR}.capture_exception")
+ @patch("posthog.temporal.common.client.async_connect", new_callable=AsyncMock)
+ def test_transient_connect_failure_is_retried_and_recovers(
+ self,
+ mock_connect: AsyncMock,
+ mock_capture: MagicMock,
+ ) -> None:
+ # async_connect() itself can fail transiently (e.g. a DNS blip reaching the Temporal
+ # frontend), raising the Rust bridge's untyped RuntimeError before any client exists —
+ # this must be retried like an RPCError, not drop the trigger on the first blip.
+ client = MagicMock()
+ client.start_workflow = AsyncMock(return_value=None)
+ mock_connect.side_effect = [RuntimeError("Failed client connect: Server connection error: ..."), client]
+
+ _trigger_post_import_workflow(self._signal())
+
+ assert mock_connect.call_count == 2
+ mock_capture.assert_not_called()
+
@patch(f"{_PROCESSOR}.capture_exception")
@patch("posthog.temporal.common.client.async_connect", new_callable=AsyncMock)
def test_persistent_rpc_timeout_is_captured_after_retries_exhausted(