Repository navigation
[2.0] Fixes #37961: Wait for the metrics worker before resetting for a new run - #38130
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 tagging changes queued-metric handling across run resets; delayed prior-run operations may be dropped, affecting per-run metric totals. Backport of the metrics worker fix so a new run no longer records an item the worker already held into the prior run. 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.0.
_lockand a stale item is dropped.generationparameter usesOptional[int]to match 2.0's typing style.test_operation_metrics.pypasses (45 tests).🤖 Generated with Claude Code


Confidence Score: 5/5
This PR appears safe to merge.Summary
This PR keeps delayed metrics from an earlier run out of the next run’s totals.
No actionable issues found. Tests were not run during this review.
Diagram
sequenceDiagram participant Q as Metrics queue participant W as Metrics worker participant R as Run reset participant S as Metrics state Q->>W: Take item tagged generation N R->>S: Under lock, advance generation and clear totals W->>S: Record item tagged generation N S-->>W: Drop stale item under lockReviews (1) · Last reviewed commit: "Fixes #37961: Wait for the metrics worke..." · Reviewed by Greptile