Repository navigation
Fixes #37961: Wait for the metrics worker before resetting for a new run - #37963
Conversation
…w 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.
❌ 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 |
…f 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.
Code Review ✅ Approved 🟡 Medium riskGeneration-tagged metrics items are dropped after a reset, changing run-summary behavior; stale operations could otherwise be attributed to the wrong run. Fixes a race where an item the metrics worker had already taken was recorded into the new run after a reset. Queued items now carry a run generation, and stale items are dropped under the same lock, so a new run no longer waits for the worker. No issues found. 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 |
…run (#37963) (#38130) * 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)
…run (#37963) (#38129) * 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)
Fixes #37961
set_run_contextdropped queued items and reset the metrics, but the item the worker had already taken was recorded after the reset, into the new run._lock, and_record_syncdrops a stale item under the same lock. A new run doesn't wait for the worker.test_new_run_drops_the_item_the_worker_is_recording: it releases the worker only after the new run has started. Fails on main every time, passes here.ADR:2026-11-16-operation-metrics-record-and-merge-under-one-lock(v2) with the generation rule.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous stale-item issue is fixed, and no new actionable issues were found.Summary
The PR prevents queued metrics from an earlier run from entering a new run.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Queue metric with current generation] --> B[Worker or summary drain takes item] C[Reset metrics under lock] --> D[Advance generation] B --> E{Item generation still current?} D --> E E -->|Yes| F[Record metric under lock] E -->|No| G[Drop stale metric]Reviews (2) · Last reviewed commit: "fix(ingestion): drop a stale metrics ite..." · Reviewed by Greptile