Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Dec 27, 2025

Why I'm doing:

Merge commit latency metrics use bvar LatencyRecorder, and the unit is nanoseconds, but if the latency is larger than 2 seconds, the bvar will report overflow as the following

image

The reason is that although LatencyRecorder accepts int64_t as input (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L100
), but it actually uses IntRecorder to store the latency as int (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L54), so the allowed latency in nanosecond is 2147483647 (about 2.1s)

class LatencyRecorder : public detail::LatencyRecorderBase {
public:
    // Record the latency.
    LatencyRecorder& operator<<(int64_t latency);
class LatencyRecorderBase {
public:
    explicit LatencyRecorderBase(time_t window_size);
    time_t window_size() const { return _latency_window.window_size(); }
protected:
    IntRecorder _latency;

What I'm doing:

bvar does not provide other recorders to support int64_t. For merge commit latency, it's not necessary to use nanosecond precision, so just change the latency unit to microsecond, and the max latency can be 35.8 minutes which should be enough.

Note changing metric unit introduces behavior change, and add the document to explain it

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.0
    • 3.5
    • 3.4
    • 3.3

Note

Fixes overflow in merge-commit latency metrics by switching from nanoseconds to microseconds and documenting the change.

  • Replace g_mc_*_latency_ns with g_mc_*_latency_us in isomorphic_batch_write.cpp, add NS_TO_US conversions, and update logs/recorders accordingly
  • No functional logic changes to write flow; only metric units and names updated
  • Add "Merge Commit BE Metrics" docs (EN/JA/ZH): new counters described; latency metrics now reported in microseconds with note about pre-v3.4.11/v3.5.12/v4.0.4 behavior

Written by Cursor Bugbot for commit 126d8f7. This will update automatically on new commits. Configure here.


This is an automatic backport of pull request #67168 done by [Mergify](https://mergify.com).

Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit 39bc4ea)

# Conflicts:
#	docs/en/administration/management/monitoring/metrics.md
#	docs/ja/administration/management/monitoring/metrics.md
#	docs/zh/administration/management/monitoring/metrics.md
@mergify
Copy link
Contributor Author

mergify bot commented Dec 27, 2025

Cherry-pick of 39bc4ea has failed:

On branch mergify/bp/branch-3.4/pr-67168
Your branch is up to date with 'origin/branch-3.4'.

You are currently cherry-picking commit 39bc4eacc4.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   be/src/runtime/batch_write/isomorphic_batch_write.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   docs/en/administration/management/monitoring/metrics.md
	both modified:   docs/ja/administration/management/monitoring/metrics.md
	both modified:   docs/zh/administration/management/monitoring/metrics.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the conflicts label Dec 27, 2025
@github-actions github-actions bot added documentation Improvements or additions to documentation automerge labels Dec 27, 2025
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) December 27, 2025 04:31
@mergify mergify bot closed this Dec 27, 2025
auto-merge was automatically disabled December 27, 2025 04:31

Pull request was closed

@mergify
Copy link
Contributor Author

mergify bot commented Dec 27, 2025

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@mergify
Copy link
Contributor Author

mergify bot commented Dec 27, 2025

🧪 CI Insights

Here's what we observed from your CI run for 2bc0cdf.

❌ Job Failures

Pipeline Job Health on branch-3.4 Retries 🔍 CI Insights 📄 Logs
CI DOC Checker markdownlint Unknown 0 View View
PR CHECKER automerge-check Unknown 0 View View

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

Labels

automerge behavior_changed conflicts documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants