Hive
Backfill project_id on first_run test_case_events rows left at the zero sentinel
GitHub issue · Open
Context
test_case_events.project_id (Int64 DEFAULT 0, denormalized in migration 20260721115000) is now relied on for project-scoped reads: PR #12215 scopes the quarantined-tests aggregate on it. While validating that PR we confirmed every state-change event type (muted, skipped, unmuted, unskipped, marked_flaky, unmarked_flaky) carries a real project_id — but first_run events do not: a subset of them still sit at the project_id = 0 sentinel.
How the zeros got there
Two populations, neither ongoing:
- Orphans predating the backfill. The
20260721115000mutation resolvedproject_idthrough a dictionary built fromtest_cases;first_runrows whose test case had since been deleted resolved to the0default and were left as-is. - A post-backfill write window.
create_first_run_eventshas setproject_id: run.project_idsince #11977, but zero-rows continued for roughly a week after the backfill before stopping abruptly — consistent with a lagging ingestion component (e.g. the separately-shipped xcresult-processor image) still running a pre-#11977 release. A portion of these rows belong to test cases that still exist, so they are cleanly fixable.
No zero-rows have been written since; the current write path is correct.
Impact
None today: first_run is an audit-log-only event type, and its reads are scoped by test_case_id. But the column now looks uniformly trustworthy — every other event type is fully backfilled — so the next project-scoped query over events (exactly what PR #12215 added for muted/skipped) would silently miss these rows. This is a data-hygiene trap worth closing while the context is fresh.
Proposed fix
- Re-run the dictionary backfill mutation from
20260721115000(same advisory-lock pattern) forevent_type = 'first_run' AND project_id = 0— this fixes the post-backfill window rows whose test cases exist. - Decide on the true orphans (test case no longer in
test_cases): either delete them (they can never render in any UI that starts from a test case) or document thatproject_id = 0onfirst_runmeans “orphaned audit row”.
Out of scope
PR #12215 is unaffected: its scoped subquery reads only muted/skipped events (fully backfilled, zero mismatches against the owning test case’s project), and the flaky-tests subquery scopes by test_case_id.
🤖 Generated with Claude Code
Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.
Start a Flight and preserve its objective, outcome, and session here.
No GitHub comments yet.