DB Olympics

Queries · q129 · VP Platform Engineering · week 1, night 2

2025 Q4 Weekly Job Failures vs Health Check Alerts

“In the window where we have both job_runs and system_health_checks data, did weeks with more unhealthy health checks line up with weeks of more job failures?”

Manager · asked the questionDiego MoralesVP Platform Engineering. Former reliability lead at a payments company. Owns uptime and the integrations merchants depend on.
Analyst · planned the reportLucas MoreauPragmatic: answers the question asked with the simplest reliable report.
Engineer · wrote the SQLInesThinks in window functions: ranks, running totals, LAG/LEAD for comparisons, percent-of-total.

Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told

  1. A business event lands on the VP Platform Engineering's desk

    Week 1; shared with Samuel Whitcombe, Head of Merchant Success

    Leadership wants a review of platform reliability in 2025: failed and slow background jobs, health check failures, rate limiting, webhook delivery problems, and which merchants felt them.

  2. Diego Morales writes to Lucas Moreau

    The manager, at the start of week 1

    Subject: 2025 platform reliability review — what I need by Friday

    Lucas,

    Leadership wants a year-in-review on platform reliability for 2025, and I'm leading it jointly with Samuel Whitcombe (Merchant Success). The deliverable is a memo that tells leadership how reliable the platform actually was last year, where it hurt merchants most, and what that implies for our 2026 investment priorities (reliability engineering headcount, which integrations/carriers to fix or replace, whether we need stricter rate limiting or SLAs). Samuel's side will map our findings to specific merchant relationships and churn risk, so where possible, surface things in a way that can be tied back to individual merchants rather than only platform-wide averages.

    Given you only get a handful of report slots a night, here's what matters most to me, roughly in priority order:

    1. How often did background work actually fail or run late in 2025, and is it getting better or worse? I want a view across the year (not just a single average) so we can see trend, not just a snapshot.
    2. When something broke, which merchants bore the brunt of it? I'd rather see a short list of the merchants hit hardest by job failures, slow jobs, or delivery problems than a platform-wide blended number — that's what Samuel needs to go have conversations.
    3. Were there periods where our own health checks told us something was wrong, and did that line up with the times merchants complained or things failed? I want to know if our monitoring is actually catching problems early or if we're flying blind.
    4. Are merchants getting throttled by our rate limits in ways that look like it's hurting their business, rather than protecting us? I want to know if this is a tuning problem or a capacity problem.
    5. How reliable are our webhook deliveries to merchants' own systems, and are there particular integrations or providers that are chronically troublesome? This feeds a build-vs-fix-vs-drop decision on a couple of integration partners.

    If you have to cut scope to fit your nightly slots, protect #1 and #2 — those are what the memo absolutely must answer. The rest can wait or be addressed at a higher level if time runs short.

    Let me know if anything above is ambiguous before you spend a slot on it.

    Diego

    A note from the Head of Merchant Success, Samuel Whitcombe

    Subject: Platform reliability review — what I need from my side

    Hi Lucas,

    As you pull together the 2025 reliability picture, here's what matters from the merchant-health side:

    1. Did our largest merchants actually feel this? For our top-tier accounts (the ones I sit QBRs with this month), can we tell whether job failures, health check issues, rate limiting or webhook problems clustered on their tenants more than the long tail — and whether it tracked with order volume or came out of nowhere?
    2. Did reliability issues coincide with commercial pain? I'd like to know if the merchants hit hardest by these issues also show signs of strain elsewhere — support tickets spiking, churn or downgrades, slower sales — so I can tell if this is a cause or just a correlation worth flagging.
    3. Any repeat offenders going into 2026? Were there a handful of merchants who got hit repeatedly through the year rather than a one-off bad week platform-wide? I want to walk into January reviews knowing who to proactively address before they raise it.

    Happy to flag specific merchant names if that helps scope the analysis.

    Best, Samuel

  3. Lucas Moreau plans the night

    The analyst · week 1, night 2, request 3 of 3

    Big surprise from night 1: Report 1 only returned 3 rows (Oct/Nov/Dec 2025) even though I asked for the full year — job_runs apparently has no rows before 2025-10-01 (clean month boundary, growing row counts, no gaps), which looks like a rolling retention window rather than a data error. Report 3 similarly only returned Nov-Dec 2025 for system_health_checks. So "year-long trend" isn't deliverable from these raw tables as asked — I'll say so plainly in the memo and work within the window that actually exists (Oct-Dec for jobs, Nov-Dec for health checks), at finer (weekly) grain to still show a trend. Also, Report 2's tenant ranking was a dead end for Diego's #2: every one of the ~10 "large" tenants had exactly 2 failed runs and the rest had 0 — that's too uniform to be a real merchant-specific signal, and likely means failures are tied to a specific job type that happens to run for every large tenant, not to anything particular about the merchant. So tonight I pivot #2 from "which tenant" to "which job type," which better serves Diego's investment-priority question, and I still owe Diego the "late" half of #1 (my first report only measured run duration, not delay/lateness) and a first test of #3 (does health-check trouble line up with job failures, in the one window where both exist).

    2025 Q4 Weekly Job Failures vs Health Check Alerts
    Question
    In the window where we have both job_runs and system_health_checks data, did weeks with more unhealthy health checks line up with weeks of more job failures?
    One row per
    ISO week (week_start date), Nov 1 - Dec 31 2025 (the overlap window both tables cover)
    Columns
    • week_start
    • total_job_runs
    • failed_job_runs
    • job_failure_rate_pct
    • total_health_checks
    • unhealthy_health_checks
    • health_check_unhealthy_rate_pct
  4. Ines writes the SQL

    The engineer · 1 dry run on the empty schema, then the submission

    Dry run 1 · STATUS: COMPILES (dry run on the empty schema, no data read)
    WITH job_week AS (
      SELECT
        cd.week_start,
        COUNT(*) AS total_job_runs,
        SUM(CASE WHEN jr.status = 'failed' THEN 1 ELSE 0 END) AS failed_job_runs
      FROM job_runs jr
      JOIN calendar_days cd ON cd.calendar_date = CAST(jr.queued_at AS date)
      WHERE jr.queued_at >= DATE '2025-11-01' AND jr.queued_at < DATE '2026-01-01'
      GROUP BY cd.week_start
    ),
    health_week AS (
      SELECT
        cd.week_start,
        COUNT(*) AS total_health_checks,
        SUM(CASE WHEN shc.is_healthy = false THEN 1 ELSE 0 END) AS unhealthy_health_checks
      FROM system_health_checks shc
      JOIN calendar_days cd ON cd.calendar_date = CAST(shc.checked_at AS date)
      WHERE shc.checked_at >= DATE '2025-11-01' AND shc.checked_at < DATE '2026-01-01'
      GROUP BY cd.week_start
    )
    SELECT
      jw.week_start,
      jw.total_job_runs,
      jw.failed_job_runs,
      ROUND(100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0), 2) AS job_failure_rate_pct,
      hw.total_health_checks,
      hw.unhealthy_health_checks,
      ROUND(100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0), 2) AS health_check_unhealthy_rate_pct
    FROM job_week jw
    JOIN health_week hw ON hw.week_start = jw.week_start
    ORDER BY jw.week_start ASC

    “Query compiles and returns the expected columns. Submitting.”

    Submitted · the SQL of the last dry run, unchanged · Submitted to tonight's batch. Your work on this request is done.

    “Submitted. The report aggregates job_runs and system_health_checks independently to ISO week (via calendar_days.week_start), filtered to Nov 1 – Dec 31 2025, then inner-joins the two weekly series on week_start so Lucas can visually compare job failure rate against health-check unhealthy rate week by week.”

  5. The report comes back overnight

    As Lucas Moreau saw it, from the small dataset the agents worked on

    week_start | total_job_runs | failed_job_runs | job_failure_rate_pct | total_health_checks | unhealthy_health_checks | health_check_unhealthy_rate_pct
    -----------+----------------+-----------------+----------------------+---------------------+-------------------------+--------------------------------
    2025-11-24 |           3861 |              20 |                 0.52 |               14832 |                     362 |                            2.44
    2025-12-01 |           3934 |               0 |                  0.0 |               25956 |                     246 |                            0.95
    2025-12-08 |           3829 |               0 |                  0.0 |               25956 |                     250 |                            0.96
    2025-12-15 |           3828 |               0 |                  0.0 |               25956 |                     271 |                            1.04
    2025-12-22 |           3828 |               0 |                  0.0 |               25956 |                     249 |                            0.96
    2025-12-29 |           1653 |               0 |                  0.0 |               11124 |                     115 |                            1.03
    (6 rows)
  6. What came of it

    The memo and the queries that followed; links found by title, so inferred

    Lucas Moreau's memo to Diego Morales at the end of the week:

    • 4. Monitoring caught it — barely, and maybe too late. Health-check unhealthy rate jumped to 2.44% the week of the incident vs. ~0.95–1.04% baseline in the surrounding weeks. Source: "2025 Q4 Weekly Job Failures vs Health Check Alerts." But ticket volume for the 10 affected tenants was already climbing 3–4 weeks before the job failures appeared in logs (1.0/tenant/week on Oct 27 → 5.8 by Nov 24). I'm not confident this is a clean "we caught it early" story — merchants may have felt it before our systems flagged it.

    Later queries that build on this report:

    It builds on:

  7. It becomes benchmark query q129

    Changed only where the benchmark needs the same result on every system

    • numericsdocs/NUMERICS.md: rounding removed; results keep full precision
    • numericsdocs/NUMERICS.md: rounding removed; results keep full precision
    • made explicita selected t.col gets AS col, its standard name made explicit (7×)
    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results
    The benchmark text, against the submitted SQL
    WITH job_week AS (  SELECT    cd.week_start,    cd.week_start AS week_start,    COUNT(*) AS total_job_runs,    SUM(CASE WHEN jr.status = 'failed' THEN 1 ELSE 0 END) AS failed_job_runs  FROM job_runs jr  JOIN calendar_days cd ON cd.calendar_date = CAST(jr.queued_at AS date)  WHERE jr.queued_at >= DATE '2025-11-01' AND jr.queued_at < DATE '2026-01-01'  GROUP BY cd.week_start),health_week AS (  SELECT    cd.week_start,    cd.week_start AS week_start,    COUNT(*) AS total_health_checks,    SUM(CASE WHEN shc.is_healthy = false THEN 1 ELSE 0 END) AS unhealthy_health_checks  FROM system_health_checks shc  JOIN calendar_days cd ON cd.calendar_date = CAST(shc.checked_at AS date)  WHERE shc.checked_at >= DATE '2025-11-01' AND shc.checked_at < DATE '2026-01-01'  GROUP BY cd.week_start)SELECT  jw.week_start,  jw.total_job_runs,  jw.failed_job_runs,  ROUND(100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0), 2) AS job_failure_rate_pct,  hw.total_health_checks,  hw.unhealthy_health_checks,  ROUND(100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0), 2) AS health_check_unhealthy_rate_pct  jw.week_start AS week_start,  jw.total_job_runs AS total_job_runs,  jw.failed_job_runs AS failed_job_runs,  100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0) AS job_failure_rate_pct,  hw.total_health_checks AS total_health_checks,  hw.unhealthy_health_checks AS unhealthy_health_checks,  100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0) AS health_check_unhealthy_rate_pctFROM job_week jwJOIN health_week hw ON hw.week_start = jw.week_startORDER BY jw.week_start ASCORDER BY jw.week_start ASC NULLS LAST
    WITH job_week AS (
      SELECT
        cd.week_start AS week_start,
        COUNT(*) AS total_job_runs,
        SUM(CASE WHEN jr.status = 'failed' THEN 1 ELSE 0 END) AS failed_job_runs
      FROM job_runs jr
      JOIN calendar_days cd ON cd.calendar_date = CAST(jr.queued_at AS date)
      WHERE jr.queued_at >= DATE '2025-11-01' AND jr.queued_at < DATE '2026-01-01'
      GROUP BY cd.week_start
    ),
    health_week AS (
      SELECT
        cd.week_start AS week_start,
        COUNT(*) AS total_health_checks,
        SUM(CASE WHEN shc.is_healthy = false THEN 1 ELSE 0 END) AS unhealthy_health_checks
      FROM system_health_checks shc
      JOIN calendar_days cd ON cd.calendar_date = CAST(shc.checked_at AS date)
      WHERE shc.checked_at >= DATE '2025-11-01' AND shc.checked_at < DATE '2026-01-01'
      GROUP BY cd.week_start
    )
    SELECT
      jw.week_start AS week_start,
      jw.total_job_runs AS total_job_runs,
      jw.failed_job_runs AS failed_job_runs,
      100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0) AS job_failure_rate_pct,
      hw.total_health_checks AS total_health_checks,
      hw.unhealthy_health_checks AS unhealthy_health_checks,
      100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0) AS health_check_unhealthy_rate_pct
    FROM job_week jw
    JOIN health_week hw ON hw.week_start = jw.week_start
    ORDER BY jw.week_start ASC NULLS LAST
    1 ms10 ms100 ms1 sHyper3.7 msDuckDB3.4 msGizmoSQL7.6 msclickhouse_brew126 msFirebolt31.1 msDataFusion56.5 msClickHouse37.9 ms
  8. Everything, as recorded

    The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted

    Ines's whole session, 7 turns
    • The request, as Ines received it
      Report request from Lucas Moreau (analyst for the VP Platform Engineering):
      
      Title: 2025 Q4 Weekly Job Failures vs Health Check Alerts
      Question: In the window where we have both job_runs and system_health_checks data, did weeks with more unhealthy health checks line up with weeks of more job failures?
      Grain: one row per ISO week (week_start date), Nov 1 - Dec 31 2025 (the overlap window both tables cover)
      Columns:
      - week_start
      - total_job_runs
      - failed_job_runs
      - job_failure_rate_pct
      - total_health_checks
      - unhealthy_health_checks
      - health_check_unhealthy_rate_pct
      Details: Two sources aggregated to the same week grain and joined: job_runs (queued_at) and system_health_checks (checked_at), both filtered to >= 2025-11-01 and < 2026-01-01, the window confirmed present in both tables from night-1 Reports 1 and 3. Group each by ISO week (calendar_days.week_start) then join on week_start; platform-wide (all tenants/components combined), no tenant filter. job_failure_rate_pct and health_check_unhealthy_rate_pct rounded to 2 decimals. Order by week_start ascending.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Ines calls dry_run
      WITH job_week AS (
        SELECT
          cd.week_start,
          COUNT(*) AS total_job_runs,
          SUM(CASE WHEN jr.status = 'failed' THEN 1 ELSE 0 END) AS failed_job_runs
        FROM job_runs jr
        JOIN calendar_days cd ON cd.calendar_date = CAST(jr.queued_at AS date)
        WHERE jr.queued_at >= DATE '2025-11-01' AND jr.queued_at < DATE '2026-01-01'
        GROUP BY cd.week_start
      ),
      health_week AS (
        SELECT
          cd.week_start,
          COUNT(*) AS total_health_checks,
          SUM(CASE WHEN shc.is_healthy = false THEN 1 ELSE 0 END) AS unhealthy_health_checks
        FROM system_health_checks shc
        JOIN calendar_days cd ON cd.calendar_date = CAST(shc.checked_at AS date)
        WHERE shc.checked_at >= DATE '2025-11-01' AND shc.checked_at < DATE '2026-01-01'
        GROUP BY cd.week_start
      )
      SELECT
        jw.week_start,
        jw.total_job_runs,
        jw.failed_job_runs,
        ROUND(100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0), 2) AS job_failure_rate_pct,
        hw.total_health_checks,
        hw.unhealthy_health_checks,
        ROUND(100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0), 2) AS health_check_unhealthy_rate_pct
      FROM job_week jw
      JOIN health_week hw ON hw.week_start = jw.week_start
      ORDER BY jw.week_start ASC
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: week_start, total_job_runs, failed_job_runs, job_failure_rate_pct, total_health_checks, unhealthy_health_checks, health_check_unhealthy_rate_pct
    • InesQuery compiles and returns the expected columns. Submitting.
    • Ines calls submit
      WITH job_week AS (
        SELECT
          cd.week_start,
          COUNT(*) AS total_job_runs,
          SUM(CASE WHEN jr.status = 'failed' THEN 1 ELSE 0 END) AS failed_job_runs
        FROM job_runs jr
        JOIN calendar_days cd ON cd.calendar_date = CAST(jr.queued_at AS date)
        WHERE jr.queued_at >= DATE '2025-11-01' AND jr.queued_at < DATE '2026-01-01'
        GROUP BY cd.week_start
      ),
      health_week AS (
        SELECT
          cd.week_start,
          COUNT(*) AS total_health_checks,
          SUM(CASE WHEN shc.is_healthy = false THEN 1 ELSE 0 END) AS unhealthy_health_checks
        FROM system_health_checks shc
        JOIN calendar_days cd ON cd.calendar_date = CAST(shc.checked_at AS date)
        WHERE shc.checked_at >= DATE '2025-11-01' AND shc.checked_at < DATE '2026-01-01'
        GROUP BY cd.week_start
      )
      SELECT
        jw.week_start,
        jw.total_job_runs,
        jw.failed_job_runs,
        ROUND(100.0 * jw.failed_job_runs / NULLIF(jw.total_job_runs, 0), 2) AS job_failure_rate_pct,
        hw.total_health_checks,
        hw.unhealthy_health_checks,
        ROUND(100.0 * hw.unhealthy_health_checks / NULLIF(hw.total_health_checks, 0), 2) AS health_check_unhealthy_rate_pct
      FROM job_week jw
      JOIN health_week hw ON hw.week_start = jw.week_start
      ORDER BY jw.week_start ASC
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • InesSubmitted. The report aggregates `job_runs` and `system_health_checks` independently to ISO week (via `calendar_days.week_start`), filtered to Nov 1 – Dec 31 2025, then inner-joins the two weekly series on `week_start` so Lucas can visually compare job failure rate against health-check unhealthy rate week by week.