Description
Summary
The analytics ETL has two related fragility issues that surfaced together as a false-alarm pattern on the data-quality alert.
1. No retry/backoff on transient GitHub failures.
The GraphQL client (analytics/src/analytics/integrations/github/client.py) issues a single requests.post and raises on any error response. The Step Function state machine (infra/modules/service/scheduled_jobs.tf) has no retry block on the RunTask state, and the EventBridge Scheduler that triggers it has maximum_retry_attempts = 0. A single transient 5xx from GitHub's GraphQL API (e.g. 504 Gateway Timeout) kills the whole extract_transform_and_load run.
Observed example: ECS task 3abc16d2d37845368eb4582763f8e847 failed on May 1, 2026 with HTTPError('504 Server Error: Gateway Timeout for url: https://api.github.com/graphql') raised inside execute_paginated_query.
2. Data-quality alert freshness check is fragile by design.
The anomaly-detector query (analytics/src/analytics/integrations/metabase/sql/133-ETL_Metrics/398-ETL_Data_Quality_Anomaly_Detector.sql) measures freshness as NOW() - MAX(t_created) for the latest d_effective. Both gh_issue_history and gh_deliverable_history UPSERT on (id, d_effective), with the do update clause advancing t_modified only. t_created stays at the first insert per d_effective per day.
The freshness reading therefore climbs continuously from ~0 at the first run of each day to ~24h right before the next day's first run. A 24h threshold fires on any missed or delayed first-run-of-the-day, even when later runs in the same day are healthy.
Goals
- The analytics ETL absorbs transient 5xx errors from GitHub without failing the run, retrying with backoff before giving up.
- The Step Function
RunTaskstate retries on transient failures with bounded backoff, as a second line of defense. - The data-quality alert measures actual ETL liveness (time since the most recent successful upsert against the latest
d_effective), so the existing 24h threshold catches real outages without firing on day-boundary timing.
Out of scope
- Schema changes to
gh_issue_historyorgh_deliverable_history. - Other anomaly-detector checks (count thresholds, sprint count, pct checks).
- Changes to the Metabase → New Relic → Slack alert plumbing outside the SQL query itself.
Reference
- Slack thread: https://betagrantsgov.slack.com/archives/C08ELDHDG6Q/p1777685582386199
- Metabase question: https://data.simpler.grants.gov/question/398
Acceptance criteria
- GraphQL client retries transient 5xx errors (502/503/504) with backoff before raising, with a bounded total attempt count.
- Step Function
RunTaskstate has a retry block covering transient task/timeout failures with bounded backoff. - Anomaly-detector freshness check measures time since the most recent successful upsert against the latest
d_effective, not time since the day's first insert. - Threshold remains at 24h after the freshness fix lands.
- Before merging: confirm the deployed Metabase question is updated to match the merged SQL. Working assumption is the
.sqlfile is copy/pasted into Metabase by hand, so the deploy step is manual and worth verifying. - Tests cover retry behavior in the GraphQL client.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
- StatusShow more project fieldsTodo
Activity