Skip to content

Fix flaky histogram window ut - #3611

Open
chenBright wants to merge 3 commits into
apache:masterfrom
chenBright:fix_histogram_ut
Open

chenBright wants to merge 3 commits into
apache:masterfrom
chenBright:fix_histogram_ut

Conversation

@chenBright

@chenBright chenBright commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

Histogram window tests can fail under high CI load because fixed sleeps and short polling timeouts
do not guarantee that the background sampler has completed the required sampling rounds

What is changed and the side effects?

Changed:

  • Replace the fixed sleep with polling that first confirms the sample enters the window, then waits for it to expire.
  • Allow 30 seconds per polling phase in both histogram window tests, checking every 100 ms.
  • Verify that expired bucket counts and sums are zero while the underlying histogram retains its cumulative values.

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Polling transient histogram values remains unreliable when sampler updates are missed.

0 open findings

What changed in this PR

This PR improves histogram window test reliability by replacing fixed waits with polling and expiration checks.

Changes:

  • Polls for asynchronous sampler updates.
  • Extends retry windows.
  • Validates expired histogram values.
File Summary
test/​bvar_histogram_unittest.cpp Updates histogram window timing and expiration assertions; polling can still miss transient results.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@wwbmmm wwbmmm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[replied by brpc-oncall robot] Test-only change: replacing the fixed sleeps with sampler-aware polling is the right direction and the new expiration assertions look correct, but the first polling phase of window_forgets_old_samples still depends on catching a transient window value, which can be missed on a busy host.

Comment thread test/bvar_histogram_unittest.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test does not prove that the window observed a non-zero sample before expiration.

1 open issue

Review effort: Lite

Comment thread test/bvar_histogram_unittest.cpp Outdated
@chenBright
chenBright requested a review from wwbmmm October 19, 2026 09:49
@wwbmmm
wwbmmm requested a lite review from Copilot October 19, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
1 resolved since last review

Review effort: Lite

Comment thread test/bvar_histogram_unittest.cpp
Comment thread test/bvar_histogram_unittest.cpp
Comment thread test/bvar_histogram_unittest.cpp
@chenBright

Copy link
Copy Markdown
Contributor Author

@wwbmmm The first two Copilot comments are false positives, and the third is an optional maintainability suggestion. No required fixes remain. This PR is ready to merge

@chenBright

Copy link
Copy Markdown
Contributor Author

@wwbmmm PTAL.

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.

3 participants