Skip to content

[2.0] Fixes #37889: Wait for the metrics worker's in-flight item before summarizing - #37899

Merged
Khairajani merged 2 commits into
2.0from
backport/2.0-operation-metrics-flush-race
Nov 17, 2026
Merged

Khairajani merged 2 commits into
2.0from
backport/2.0-operation-metrics-flush-race

Conversation

@Khairajani

@Khairajani Khairajani commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #37890 to 2.0. Fixes #37889

🤖 Generated with Claude Code


Summary by Gitar

  • Worker and queue handling:
    • Worker marks every dequeued item done in a finally block so flushes never hang
    • New _drain_async_queue helper is shared by shutdown, clearing, and summary flushes
  • Fallback recording:
    • Records synchronously via _record_sync when _worker_is_alive() returns false

This will update automatically on new commits.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previous documentation finding fully addressed.

Summary

The PR makes metrics summaries wait for work already taken by the background worker and puts recording and merging under the same lock.

  • Metric summaries wait briefly for the worker to finish in-flight items.
  • Concurrent metric writes and merges use one lock.

Reviews (2) · Last reviewed commit: "docs: the metrics flush ADR bounds only ..." · Reviewed by Greptile

…marizing (#37890)

* fix(ingestion): wait for the metrics worker's in-flight item before summarizing

* fix(ingestion): record the metrics flush and lock decisions, make the race test deterministic

- Release the held worker only once the summary waits on the queue, so the
  regression test cannot pass without the fix.
- Read thread ids under the lock in merge_all_threads.
- Update the docstring and field comment that still called recording lock-free.
- Add decision records for the 1s flush wait and the shared record/merge lock.

* docs: state when a metrics summary read can take the full flush wait

(cherry picked from commit 930926a)
@Khairajani
Khairajani requested a review from a team as a code owner November 16, 2026 13:26
@Khairajani
Khairajani requested review from stout-yeoman and removed request for a team November 16, 2026 13:26
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@gitar-bot

gitar-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Locking metric recording and merging, plus bounded queue flushing, changes in-process aggregation; a one-second timeout could leave in-flight metrics out of summaries.

Backport of the metrics worker fix to 2.0: summary reads now wait up to 1s for the worker's in-flight item, and recording and merging share a lock. Worker marks dequeued items done in a finally block, and a shared _drain_async_queue helper covers shutdown, clearing, and summary flushes. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Khairajani
Khairajani merged commit 1a5801b into 2.0 Nov 17, 2026
68 of 71 checks passed
@Khairajani
Khairajani deleted the backport/2.0-operation-metrics-flush-race branch November 17, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant