Repository navigation
fix(alerts): keep platform insight checks out of query single flights - #127919
Conversation
A platform insight check and the production check of the same alert run the same query at the same moment. They sit in different single-flight partitions, because the partition includes the ClickHouse user, but they write one cache entry. When production writes after the platform leader, the platform followers find an entry that is not their leader's and fail with QueryRanConcurrently. Add skip_query_single_flight(), a context-scoped opt-out the runner checks before it joins a flight, and enter it around each platform insight check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check the skip before the flag evaluation, name every other writer in the platform comment, and simplify the test helper's side effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
😎 Merged successfully - details. |
🤖 CI report
|
| File | Comment lines | Added lines |
|---|---|---|
products/alerts/backend/platform_source_cycle.py |
2 | 12 |
This check does not block merging. It updates on every push and clears when the share drops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Risk: No findings This PR adds a context-scoped Sentinel reviewed |
There was a problem hiding this comment.
Approved.
The shared query-cache coordination change enters risky territory, with owning-team authorship providing assurance and focused tests covering the opt-out. No unresolved review concerns or other refusal grounds were found.
- Author wrote 62% of the modified lines and has 24 merged PRs in these paths (familiarity MODERATE).
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 48L, 3F substantive, 85L/5F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1b-small (85L, 5F, two-areas, fix) |
| stamphog 2.7.0 | .stamphog/policy.yml @ 718fed3 · reviewed head 718fed3 |
|
/trunk merge |
Problem
single_flight_variantputs that user in the flight partition. The cache entry has no such partition._serve_flight_outcomeraisesQueryRanConcurrently.Changes
skip_query_single_flight()context manager makes_joins_single_flightreturn false inside it. The platform enters it around each check.How did you test this code?
Test rationale:
skipped_by_the_callercase intest_runs_that_cannot_share_a_result_never_touch_the_flightputs the run behind a held flight. It catches the skip check being dropped from the runner. Without the fix it raisedQueryRanConcurrently.test_a_breach_fires_on_the_platform_and_leaves_the_production_alert_alonenow checks the skip during the platform query. It catches thewithbeing dropped from the platform path.Release status
Docs update
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5 (
claude-opus-5-5)Skills:
/writing-tests,/simplify,/code-review,/reviewing-with-coderabbit,/writing-pr-descriptions,/pr-sessionsMore context for AI agents
posthog/hogql_queries/query_runner.py_joins_single_flight, the only shared-runner change🤖 Generated with Claude Code