Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #7381] Fix the problem of inaccurate timer message metric #7382

Merged
merged 4 commits into from
Sep 23, 2023

Conversation

GenerousMan
Copy link
Contributor

Which Issue(s) This PR Fixes

Fixes #7381

Brief Description

When entering the time wheel, if it is judged that it can be dequeued, its enqueue time is set to infinity, which means that it has never entered the time wheel.

Skip messages with an infinite enqueue time when counting metrics.

How Did You Test This Change?

@@ -599,7 +599,12 @@ public void addMetric(MessageExt msg, int value) {
if (null == msg || null == msg.getProperty(MessageConst.PROPERTY_REAL_TOPIC)) {
return;
}
timerMetrics.addAndGet(msg.getProperty(MessageConst.PROPERTY_REAL_TOPIC), value);
if (msg.getProperty(TIMER_ENQUEUE_MS) != null
Copy link
Contributor

Choose a reason for hiding this comment

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

NumberUtils.toLong() might be more clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

no need of msg.getProperty(TIMER_ENQUEUE_MS) != null if using NumberUtils.toLong, you can check this out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Under normal situation, this indicator is still null when exiting the queue, so this judgment is necessary.
When leaving the queue, the 'enququ_time' attribute in the message has not been retrieved from the timerRequest yet. When leaving the queue, this attribute will not be null unless it is determined that it has never entered the time wheel.

DefaultStoreMetricsManager.incTimerDequeueCount(getRealTopic(msgExt));
if (tr.getEnqueueTime() == Long.MAX_VALUE) {
// never enqueue, mark it.
MessageAccessor.putProperty(msgExt, TIMER_ENQUEUE_MS, Long.MAX_VALUE+"");
Copy link
Contributor

Choose a reason for hiding this comment

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

will String.valueOF(Long.MAX_VALUE) be more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@codecov-commenter
Copy link

Codecov Report

Merging #7382 (2ae68d7) into develop (b8610d8) will increase coverage by 0.00%.
Report is 2 commits behind head on develop.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             develop    #7382   +/-   ##
==========================================
  Coverage      42.51%   42.52%           
- Complexity      9440     9442    +2     
==========================================
  Files           1150     1150           
  Lines          82728    82738   +10     
  Branches       10775    10778    +3     
==========================================
+ Hits           35174    35182    +8     
- Misses         43143    43148    +5     
+ Partials        4411     4408    -3     
Files Changed Coverage Δ
.../org/apache/rocketmq/store/timer/TimerRequest.java 88.23% <0.00%> (-5.52%) ⬇️
...apache/rocketmq/store/timer/TimerMessageStore.java 53.57% <54.54%> (-0.18%) ⬇️
.../org/apache/rocketmq/store/timer/TimerMetrics.java 67.66% <100.00%> (+0.24%) ⬆️

... and 13 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

LGTM

@RongtongJin RongtongJin merged commit 88a9d93 into apache:develop Sep 23, 2023
10 checks passed
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.

[Bug] The metrics of timerMessage are inaccurate and may even be negative.
5 participants