Skip to content

fix(buffers): Stop reporting usage for dropped buffers - #25994

Open
bruceg wants to merge 1 commit into
masterfrom
bruceg/fix-buffer-reporting-drop
Open

fix(buffers): Stop reporting usage for dropped buffers#25994
bruceg wants to merge 1 commit into
masterfrom
bruceg/fix-buffer-reporting-drop

Conversation

@bruceg

@bruceg bruceg commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

The buffer usage reporter looped forever, so it outlived the buffer it reported on. After a configuration reload replaced a sink's buffer, the reporter for the old buffer kept publishing gauges under the same buffer_id as its replacement, and both the task and the stage state it held were retained for the life of the process.

The reporter now discards each stage once it holds the only remaining reference to it, after one final report to pick up the deltas recorded since the previous tick, and the task ends once no stages remain. That also lets the metrics for a buffer which was removed rather than replaced expire.

Since the reporter's lifetime now depends on the buffer holding on to its usage handle, that requirement is documented on IntoBuffer::provides_instrumentation.

Vector configuration

How did you test this PR?

See unit tests. This was uncovered while expanding the buffers' benchmark set.

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

The buffer usage reporter looped forever, so it outlived the buffer it reported
on. After a configuration reload replaced a sink's buffer, the reporter for the
old buffer kept publishing gauges under the same `buffer_id` as its replacement,
and both the task and the stage state it held were retained for the life of the
process.

The reporter now discards each stage once it holds the only remaining reference
to it, after one final report to pick up the deltas recorded since the previous
tick, and the task ends once no stages remain. That also lets the metrics for a
buffer which was removed rather than replaced expire.

Since the reporter's lifetime now depends on the buffer holding on to its usage
handle, that requirement is documented on `IntoBuffer::provides_instrumentation`.
@bruceg
bruceg requested a review from graphcareful August 1, 2026 04:20
@bruceg
bruceg requested a review from a team as a code owner August 1, 2026 04:20
@bruceg bruceg added domain: observability Anything related to monitoring/observing Vector domain: buffers Anything related to Vector's memory/disk buffers type: bug A bug fix labels Aug 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d45a67be2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +429 to +433
stage.report(current_metrics, buffer_id);

// Every handle for the stage has been dropped once the reporter holds the only remaining
// reference, and no new handle can appear from a count of one.
Arc::strong_count(stage) > 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check liveness before making the final report

When the last BufferUsageHandle is active concurrently with this tick, stage.report can consume a category before that handle records its final update; if the handle then updates the counter and drops before strong_count is checked, this returns false and permanently discards the unreported delta. Capture whether another reference exists before calling report, so a stage that was live at the start of the tick is retained for one more, race-free final report.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: buffers Anything related to Vector's memory/disk buffers domain: observability Anything related to monitoring/observing Vector type: bug A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant