Skip to content

fix(data-warehouse): retry UNAVAILABLE rpc status in temporalio source - #73361

Merged
talyn-app[bot] merged 1 commit into
masterfrom
posthog-code/temporalio-retry-unavailable-rpc
Jul 24, 2026
Merged

fix(data-warehouse): retry UNAVAILABLE rpc status in temporalio source#73361
talyn-app[bot] merged 1 commit into
masterfrom
posthog-code/temporalio-retry-unavailable-rpc

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

The Temporal.io warehouse import wraps its list_workflows/fetch_next_page/fetch_history calls in _with_transient_rpc_retry to ride out transient server blips. The retryable set covers RESOURCE_EXHAUSTED, DEADLINE_EXCEEDED, and a couple of message-matched cases (h2 protocol error, Timeout expired), but not gRPC status UNAVAILABLE.

An error-tracking issue surfaced an RPCError with message dns error (gRPC status code 14, i.e. UNAVAILABLE) — a transient connection-level failure resolving the cluster's frontend host. Since UNAVAILABLE wasn't in the retryable set, the helper re-raised on the first attempt instead of backing off, failing the whole import activity (which rebuilds the client and restarts pagination) for what should have been a one-off blip.

I checked for an existing fix first: #71792 attempted something similar (adding UNAVAILABLE plus a message-fragment match), but it now conflicts with master (mergeable: false) since a separate change independently landed the h2 protocol error/Timeout expired message-matching this PR's base already has. So it doesn't cleanly cover this case as-is; this PR adds UNAVAILABLE fresh against current master.

Changes

Add RPCStatusCode.UNAVAILABLE to _RETRYABLE_RPC_STATUSES — an unambiguously transient connection-level gRPC status, so it gets the same in-process backoff as the existing rate-limit and deadline cases. Persistent failures still re-raise so Temporal's activity-level retry applies.

How did you test this code?

Extended the existing parametrized TestTransientRPCRetry tests in test_temporalio.py:

  • Added a dns error / UNAVAILABLE row to test_rides_out_transient_error — locks in that this connection-level status now backs off and retries rather than failing immediately (the regression this PR fixes).
  • Added the same row to test_persistent_transient_error_is_reraised — confirms a persistent UNAVAILABLE failure still re-raises after exhausting attempts, same as the other retryable statuses.

Ran pytest products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py::TestTransientRPCRetry (11 passed), plus ruff check/ruff format --check.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No user-facing behavior or documented workflow changes.

🤖 Agent context

Autonomy: Fully autonomous

Authored by PostHog Code (Claude) triaging an error-tracking issue where a single dns error RPCError failed a Temporal.io warehouse import activity. Root cause: _RETRYABLE_RPC_STATUSES didn't include UNAVAILABLE (gRPC status 14), which is what a DNS resolution blip surfaces as.

Before implementing, checked for a duplicate fix among open PRs (search on "temporalio", "RPCError", "dns error", plus the maintainer's own open PRs). Found #71792, which targets the same helper and a similar connection-level retry gap, but its base has since diverged (another change independently added message-based matching for h2 protocol error/Timeout expired), leaving it in a conflicting state that doesn't apply cleanly. This PR makes the narrower, still-missing addition (UNAVAILABLE by status) against current master.

Invoked /writing-tests before extending test coverage — the added cases are parametrize rows on the existing retry tests, not new test functions.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Gilbert09! 👋

It looks like your git author email on this PR isn't your @posthog.com address (owerstom@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 23, 2026 20:57
@Gilbert09 Gilbert09 added the stamphog Request AI approval (no full review) label Jul 23, 2026 — with PostHog
stamphog[bot]
stamphog Bot previously approved these changes Jul 23, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small, well-tested retry-logic fix (add gRPC UNAVAILABLE to a transient-retry set) in a data warehouse import helper; the other 56 files are purely mechanical import-reordering in auto-generated MCP tool files with no logic changes. No risky territory touched, cross-team authorship is only a routing signal here.

  • Author wrote 3% of the modified lines and has 12 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 13L, 1F substantive, 479L/58F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (479L, 58F, two-areas, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 4bf3017 · reviewed head 7537d5f

@posthog-bot-comment-resolver

posthog-bot-comment-resolver Bot commented Jul 24, 2026

Copy link
Copy Markdown

🔀 Tried to auto-resolve conflicts with master but this one needs a human.

I won't retry until the branch or master moves.

The Temporal.io warehouse import wraps its list/fetch calls in `_with_transient_rpc_retry` to ride out transient server blips, but the retryable status set only covered `RESOURCE_EXHAUSTED` and `DEADLINE_EXCEEDED` (plus a couple of message-matched cases). A DNS resolution blip on the client's connection to the cluster surfaces as gRPC status `UNAVAILABLE`, which fell outside both the status set and the message matchers, so it re-raised and failed the import activity instead of backing off.

Adds `UNAVAILABLE` to the retryable status set alongside the existing statuses.

Generated-By: PostHog Code
Task-Id: 4f93ee01-af88-41c0-9adc-2f91b54e9a1a
@Gilbert09
Gilbert09 force-pushed the posthog-code/temporalio-retry-unavailable-rpc branch from 7537d5f to 179b6a1 Compare July 24, 2026 13:10
@stamphog
stamphog Bot dismissed their stale review July 24, 2026 13:11

New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.

@talyn-app
talyn-app Bot enabled auto-merge (squash) July 24, 2026 13:11

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial, well-tested addition of a retryable gRPC status code by an author with strong familiarity on the owning team; no risky territory touched.

  • Author wrote 100% of the modified lines and has 6 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 13L, 1F substantive, 17L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1a-trivial (17L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 7ed0f2d · reviewed head 179b6a1

@talyn-app
talyn-app Bot merged commit 4221205 into master Jul 24, 2026
237 checks passed
@talyn-app
talyn-app Bot deleted the posthog-code/temporalio-retry-unavailable-rpc branch July 24, 2026 13:43
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-24 14:42 UTC Run
prod-us ✅ Deployed 2026-07-24 14:58 UTC Run
prod-eu ✅ Deployed 2026-07-24 15:01 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant