Skip to content

Fix flaky latency recorder QPS test - #3651

Open
songgaoye wants to merge 3 commits into
apache:masterfrom
songgaoye:fix-bvar-recorder-qps-test
Open

songgaoye wants to merge 3 commits into
apache:masterfrom
songgaoye:fix-bvar-recorder-qps-test

Conversation

@songgaoye

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

RecorderTest.latency_recorder_qps_accuracy is flaky because it calculates the expected QPS from one window sample and then reads qps() separately. A sampler tick can occur between those reads, causing them to refer to different windows and resulting in intermittent zero or inaccurate QPS assertions.

What is changed and the side effects?

Changed:

  • Retry the QPS assertion when the latency-window sample changes between reads.
  • Compare qps() with the expected value only when the samples immediately before and after the QPS read have the same timestamp.

Side effects:

  • Performance effects: Test-only change. Negligible additional polling in the rare case of a sampler tick during validation.
  • Breaking backward compatibility: None.

Check List:

@chenBright
chenBright requested a balanced review from Copilot October 24, 2026 07:14

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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 current test can validate an unintended 2-second window and can compare QPS values from different samples.

1 open issue

Review effort: Lite

Comment thread test/bvar_recorder_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 revised test can still validate incorrect windows and remain flaky under the sampler race.

1 open issue
1 resolved since last review

Review effort: Lite

Comment thread test/bvar_recorder_unittest.cpp

@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] The rework addresses the previous round (dedicated 2s/3s recorders plus a full-window guard), and Copilot's claim about has_full_latency_window() does not hold; only the one-tick observation interval remains a residual scheduling risk.

Comment thread test/bvar_recorder_unittest.cpp
Comment thread test/bvar_recorder_unittest.cpp

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

Address the two moderate test-synchronization issues before approval.

No open issues 🎉

1 resolved since last review

Review effort: Lite

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