DB Olympics

Queries · q340 · VP Platform Engineering · week 2, night 2

Ticket Subject Lines from Affected Merchants Before the Nov 24 Failures

“In the weeks before the carts.remind failures showed up in our logs, did the 10 affected merchants' shoppers raise tickets that look related to carts, reminders, or duplicate/missing emails?”

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 SQLBeaWrites SQL the way the company's BI tool generates it: verbose fully qualified aliases (t0, t1, ...), a subquery per measure joined back on the grain keys, COALESCE everywhere.

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 2

    Subject: Re: 2025 Platform Reliability Review — good start, a few things I need tightened up

    Lucas,

    Thanks — this is useful and more honest than I expected on the limits of what we can see. A few things stood out and need more work before Friday's memo goes to leadership.

    First, the retention gap is itself a finding, not just a caveat. We're flying with 90 days of job history and 60 days of health-check history — that means we genuinely don't know how 2025 looked before October. I want that stated plainly and separately in the memo as a reliability/observability gap in its own right, not buried as a footnote under the carts.remind story.

    Second, the ERP/WMS/Accounting webhook stuck-retry pattern is, to me, the most important and actionable thing in here — more than the one-week carts.remind incident. I want that properly validated and sized, not eyeballed, before we say anything about it to leadership.

    Questions for this week:

    1. Can you redo the webhook comparison correctly and tell me: how many merchants are affected by this stuck-retry pattern, and what's the revenue or order volume behind them? I want to know if this is a handful of our biggest accounts or a long tail.
    2. Has the ~15% stuck-retry rate on those sync webhooks been happening all year, or is it new/recent? Even without full job history, is there any way to tell whether this is a longstanding bug we've lived with or something that regressed recently?
    3. On carts.remind — you said it looks tied to a feature flag or config rather than load. Can we get more confidence on that? I want to know if this is a one-off we already fixed, or a latent risk that could recur with other job types.
    4. Setting aside strict proof of causation, can you give me your best read on whether the ticket-volume climb for the 10 affected tenants in the weeks before the failures showed up in our logs is something merchants were telling us about directly (i.e., check if their tickets mention sync/reminders/missing carts) — even a rough read would tell us if our support channel was effectively an early warning system we ignored.

    On rate limiting: agreed, drop it for this cycle — don't spend a slot trying to force an answer out of config data alone. Just flag it as a 2026 instrumentation ask, as you already have.

    Priority for your remaining slots: #1 and #2 above. The webhook/sync issue is the one I can take into a fix-it conversation with engineering next week if the numbers hold up — I'd rather have that nailed down than more polish on the carts.remind narrative.

    Diego

  3. Lucas Moreau plans the night

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

    Night 1 results reshape the story in an important way. Report 1 shows the stuck-retry pattern touches 56 tenants (not a handful) at wildly different % rates, but many of the worst percentages (e.g. 50%, 38%) are tiny-volume tenants (1-2 stuck deliveries) - a small-sample artifact, not a real signal. When I compute absolute stuck-delivery counts (rate x volume) by hand from that report, ~91% of all stuck deliveries sit with just 4 tenants: Brennquell Kaffee (~1,574 stuck), Cragsley Outfitters (~700), Ampfeld Elektronik (~161), and Marrowby & Vane (~88) - and these are the same 4 of our 10 carts.remind-affected tenants with real order volume. That's the concentration story Diego wants, and I don't need another slot to prove it, it's derivable from what we have. Report 2 shows the platform-wide stuck rate has been flat at ~5.2-6.6% every month all year (not the ~15% I quoted last week, which was a selection-biased view of only the worst 20 endpoints) - so no recent regression at the platform level. Report 3 is a clean, high-confidence answer on carts.remind: all 20 failures are the identical error ('503 Service Unavailable: storefront API') in two one-hour-apart batches on Nov 28, across the same 10 tenants both times - this reads as a brief outage of one shared upstream dependency, not a tenant-specific or load issue, and not really a 'config/feature flag' story as I speculated last week. Tonight I'll: (1) check whether the stuck rate for those same 4 high-impact tenants has itself been stable all year or is recent/worsening (refines Diego's #2 to the account level that matters for the fix-it conversation); (2) pull internal health checks around the Nov 28 14:00-16:00 window to see if monitoring caught the storefront-API blip in real time (closes out #3 with hard evidence); (3) do a first lightweight look at ticket subject lines from the 10 affected tenants in the weeks before Nov 24 to give Diego his requested 'rough read' on whether support was an early warning signal (#4).

    Ticket Subject Lines from Affected Merchants Before the Nov 24 Failures
    Question
    In the weeks before the carts.remind failures showed up in our logs, did the 10 affected merchants' shoppers raise tickets that look related to carts, reminders, or duplicate/missing emails?
    One row per
    ticket
    Columns
    • tenant_name
    • created_at
    • subject
    • status
    • priority
  4. Bea 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)
    SELECT
        t2.name AS tenant_name,
        t0.created_at AS created_at,
        t0.subject AS subject,
        t0.status AS status,
        t0.priority AS priority
    FROM tickets t0
    JOIN users t1 ON t1.id = t0.requester_user_id
    JOIN tenants t2 ON t2.id = t1.tenant_id
    WHERE t2.name IN (
        'Ampfeld Elektronik',
        'Brennquell Kaffee',
        'Cinder Peak Sports Co.',
        'Cragsley Outfitters',
        'Fennel & Flint',
        'Gratlinie Outdoor',
        'Kibblewick',
        'Marrowby & Vane',
        'Petalcourt Beauty',
        'Studio Vrij'
    )
    AND t0.created_at >= DATE '2025-10-27'
    AND t0.created_at < DATE '2025-11-24'
    AND (
        lower(t0.subject) LIKE '%cart%'
        OR lower(t0.subject) LIKE '%remind%'
        OR lower(t0.subject) LIKE '%duplicate%'
        OR lower(t0.subject) LIKE '%missing%'
        OR lower(t0.subject) LIKE '%email%'
    )
    ORDER BY t0.created_at ASC, t0.id 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 joins tickets → users (on requester_user_id) → tenants, filters to the 10 named merchants, the Oct 27–Nov 23 2025 window, and subject lines matching cart/remind/duplicate/missing/email (case-insensitive), ordered by created_at ascending with a tie-break on ticket id for determinism.”

  5. The report comes back overnight

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

    tenant_name | created_at | subject | status | priority
    ------------+------------+---------+--------+---------
    (0 rows)
  6. What came of it

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

    It builds on:

  7. It becomes benchmark query q340

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

    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results (2×)
    The benchmark text, against the submitted SQL
    SELECT    t2.name AS tenant_name,    t0.created_at AS created_at,    t0.subject AS subject,    t0.status AS status,    t0.priority AS priorityFROM tickets t0JOIN users t1 ON t1.id = t0.requester_user_idJOIN tenants t2 ON t2.id = t1.tenant_idWHERE t2.name IN (    'Ampfeld Elektronik',    'Brennquell Kaffee',    'Cinder Peak Sports Co.',    'Cragsley Outfitters',    'Fennel & Flint',    'Gratlinie Outdoor',    'Kibblewick',    'Marrowby & Vane',    'Petalcourt Beauty',    'Studio Vrij')AND t0.created_at >= DATE '2025-10-27'AND t0.created_at < DATE '2025-11-24'AND (    lower(t0.subject) LIKE '%cart%'    OR lower(t0.subject) LIKE '%remind%'    OR lower(t0.subject) LIKE '%duplicate%'    OR lower(t0.subject) LIKE '%missing%'    OR lower(t0.subject) LIKE '%email%')ORDER BY t0.created_at ASC, t0.id ASCORDER BY t0.created_at ASC NULLS LAST, t0.id ASC NULLS LAST
    SELECT
        t2.name AS tenant_name,
        t0.created_at AS created_at,
        t0.subject AS subject,
        t0.status AS status,
        t0.priority AS priority
    FROM tickets t0
    JOIN users t1 ON t1.id = t0.requester_user_id
    JOIN tenants t2 ON t2.id = t1.tenant_id
    WHERE t2.name IN (
        'Ampfeld Elektronik',
        'Brennquell Kaffee',
        'Cinder Peak Sports Co.',
        'Cragsley Outfitters',
        'Fennel & Flint',
        'Gratlinie Outdoor',
        'Kibblewick',
        'Marrowby & Vane',
        'Petalcourt Beauty',
        'Studio Vrij'
    )
    AND t0.created_at >= DATE '2025-10-27'
    AND t0.created_at < DATE '2025-11-24'
    AND (
        lower(t0.subject) LIKE '%cart%'
        OR lower(t0.subject) LIKE '%remind%'
        OR lower(t0.subject) LIKE '%duplicate%'
        OR lower(t0.subject) LIKE '%missing%'
        OR lower(t0.subject) LIKE '%email%'
    )
    ORDER BY t0.created_at ASC NULLS LAST, t0.id ASC NULLS LAST
    1 ms10 ms100 msHyper3.8 msDuckDB7.7 msGizmoSQL8.6 msclickhouse_brew32.9 msFirebolt24.3 msDataFusion61.9 msClickHouse24.8 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

    Bea's whole session, 7 turns
    • The request, as Bea received it
      Report request from Lucas Moreau (analyst for the VP Platform Engineering):
      
      Title: Ticket Subject Lines from Affected Merchants Before the Nov 24 Failures
      Question: In the weeks before the carts.remind failures showed up in our logs, did the 10 affected merchants' shoppers raise tickets that look related to carts, reminders, or duplicate/missing emails?
      Grain: one row per ticket
      Columns:
      - tenant_name
      - created_at
      - subject
      - status
      - priority
      Details: Table tickets joined to users (requester_user_id) to get tenant_id, joined to tenants for tenant_name. Filter requester's tenant_id in the 10 carts.remind-affected tenants (Ampfeld Elektronik, Brennquell Kaffee, Cinder Peak Sports Co., Cragsley Outfitters, Fennel & Flint, Gratlinie Outdoor, Kibblewick, Marrowby & Vane, Petalcourt Beauty, Studio Vrij) and created_at >= 2025-10-27 and < 2025-11-24. Additionally filter to tickets whose subject matches (case-insensitive) any of: '%cart%', '%remind%', '%duplicate%', '%missing%', '%email%'. Order by created_at ascending. If more than 50 rows match, note the total count; otherwise return all.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Bea calls dry_run
      SELECT
          t2.name AS tenant_name,
          t0.created_at AS created_at,
          t0.subject AS subject,
          t0.status AS status,
          t0.priority AS priority
      FROM tickets t0
      JOIN users t1 ON t1.id = t0.requester_user_id
      JOIN tenants t2 ON t2.id = t1.tenant_id
      WHERE t2.name IN (
          'Ampfeld Elektronik',
          'Brennquell Kaffee',
          'Cinder Peak Sports Co.',
          'Cragsley Outfitters',
          'Fennel & Flint',
          'Gratlinie Outdoor',
          'Kibblewick',
          'Marrowby & Vane',
          'Petalcourt Beauty',
          'Studio Vrij'
      )
      AND t0.created_at >= DATE '2025-10-27'
      AND t0.created_at < DATE '2025-11-24'
      AND (
          lower(t0.subject) LIKE '%cart%'
          OR lower(t0.subject) LIKE '%remind%'
          OR lower(t0.subject) LIKE '%duplicate%'
          OR lower(t0.subject) LIKE '%missing%'
          OR lower(t0.subject) LIKE '%email%'
      )
      ORDER BY t0.created_at ASC, t0.id ASC
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: tenant_name, created_at, subject, status, priority
    • BeaQuery compiles and returns the expected columns. Submitting.
    • Bea calls submit
      SELECT
          t2.name AS tenant_name,
          t0.created_at AS created_at,
          t0.subject AS subject,
          t0.status AS status,
          t0.priority AS priority
      FROM tickets t0
      JOIN users t1 ON t1.id = t0.requester_user_id
      JOIN tenants t2 ON t2.id = t1.tenant_id
      WHERE t2.name IN (
          'Ampfeld Elektronik',
          'Brennquell Kaffee',
          'Cinder Peak Sports Co.',
          'Cragsley Outfitters',
          'Fennel & Flint',
          'Gratlinie Outdoor',
          'Kibblewick',
          'Marrowby & Vane',
          'Petalcourt Beauty',
          'Studio Vrij'
      )
      AND t0.created_at >= DATE '2025-10-27'
      AND t0.created_at < DATE '2025-11-24'
      AND (
          lower(t0.subject) LIKE '%cart%'
          OR lower(t0.subject) LIKE '%remind%'
          OR lower(t0.subject) LIKE '%duplicate%'
          OR lower(t0.subject) LIKE '%missing%'
          OR lower(t0.subject) LIKE '%email%'
      )
      ORDER BY t0.created_at ASC, t0.id ASC
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • BeaSubmitted. The report joins `tickets` → `users` (on `requester_user_id`) → `tenants`, filters to the 10 named merchants, the Oct 27–Nov 23 2025 window, and subject lines matching cart/remind/duplicate/missing/email (case-insensitive), ordered by `created_at` ascending with a tie-break on ticket id for determinism.