Repository navigation
[2.1] Fixes #37961: Wait for the metrics worker before resetting for a new run - #38129
Conversation
…run (#37963) * fix(ingestion): wait for the metrics worker before resetting for a new run An item the worker held when a new run started was recorded after the reset, into the new run. set_run_context now waits for it, under the same 1s bound as summary reads, before resetting. * fix(ingestion): drop a stale metrics item by run generation instead of waiting The bounded wait still leaked an item the worker recorded after it expired. Queued items now carry the run generation; a reset bumps it under the lock and _record_sync drops a stale item. A new run no longer waits. (cherry picked from commit 96ebbcd)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved 🟡 Medium riskGeneration checks make metrics resets drop stale worker items, preventing cross-run metric contamination; the change is limited to operation metrics. Fixes a race where a metrics worker item already held at the start of a new run was recorded into that run after the reset. Queued items now carry a run generation, and a reset bumps it under VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Backport of #37963 to 2.1.
_lockand a stale item is dropped.test_operation_metrics.pypasses (45 tests).🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
This backport keeps queued metrics from an earlier run out of a new run.
No actionable issues found. Tests were not run during this review.
Diagram
sequenceDiagram participant P as Recording thread participant Q as Metrics queue participant W as Metrics worker participant R as New run P->>Q: Queue item with generation N Q->>W: Take item R->>R: Under lock, advance generation and clear metrics W->>W: Under lock, compare generations W->>W: Drop stale itemReviews (1) · Last reviewed commit: "Fixes #37961: Wait for the metrics worke..." · Reviewed by Greptile