Skip to content

Analytics ETL: add retry/backoff and fix alert freshness mechanic #1098

Open

Description

@SnowboardTechie

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 RunTask state 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_history or gh_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

Acceptance criteria

  • GraphQL client retries transient 5xx errors (502/503/504) with backoff before raising, with a bounded total attempt count.
  • Step Function RunTask state 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 .sql file is copy/pasted into Metabase by hand, so the deploy step is manual and worth verifying.
  • Tests cover retry behavior in the GraphQL client.

Activity

  1. added
    fixFix to the published version. Goes straight to main.
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixFix to the published version. Goes straight to main.

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions