Skip to content

[fix][broker] Fix issue where msgRateExpired may not refresh forever - #19759

Merged
Technoboy- merged 1 commit into
apache:masterfrom
massakam:fix-expiration-rate
Mar 12, 2023
Merged

Technoboy- merged 1 commit into
apache:masterfrom
massakam:fix-expiration-rate

Conversation

@massakam

@massakam massakam commented Mar 9, 2023 •

Copy link
Copy Markdown
Contributor

Motivation

Topic stats have a msgRateExpired field. Once this value is greater than 0, it may never return to 0, even though no messages have expired. This is because PersistentMessageExpiryMonitor#updateRates() only runs when PersistentMessageExpiryMonitor#expireMessages() is executed, not periodically.

For example, if the number of messages in the backlog of a subscription is 0, the execution of PersistentMessageExpiryMonitor#expireMessages() will be skipped and msgRateExpired will not be updated.

public boolean expireMessages(int messageTTLInSeconds) {
if ((getNumberOfEntriesInBacklog(false) == 0) || (dispatcher != null && dispatcher.isConsumerConnected()
&& getNumberOfEntriesInBacklog(false) < MINIMUM_BACKLOG_FOR_EXPIRY_CHECK
&& !topic.isOldestMessageExpired(cursor, messageTTLInSeconds))) {
// don't do anything for almost caught-up connected subscriptions
return false;
}
this.lastExpireTimestamp = System.currentTimeMillis();
return expiryMonitor.expireMessages(messageTTLInSeconds);
}

As a result, the value of msgRateExpired may remain non-zero even though message expiration has not occurred recently.

Modifications

Call PersistentMessageExpiryMonitor#updateRates() in the PersistentTopic#updateRates() method that runs periodically to update the topic stats.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@massakam massakam added type/bug The PR fixed a bug or issue reported a bug component/stats doc-not-needed Your PR changes do not impact docs ready-to-test labels Mar 9, 2023
@massakam massakam added this to the 3.0.0 milestone Mar 9, 2023
@massakam massakam self-assigned this Mar 9, 2023
@massakam massakam changed the title [fix][stats] Fix issue where msgRateExpired may not refresh forever [fix][broker] Fix issue where msgRateExpired may not refresh forever Mar 9, 2023
@codecov-commenter

codecov-commenter commented Mar 9, 2023 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.01%. Comparing base (e973388) to head (1db15cf).
⚠️ Report is 2760 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #19759       +/-   ##
=============================================
+ Coverage     32.05%   62.01%   +29.95%     
- Complexity     6409    25829    +19420     
=============================================
  Files          1674     1848      +174     
  Lines        126556   135887     +9331     
  Branches      13810    14953     +1143     
=============================================
+ Hits          40570    84264    +43694     
+ Misses        79992    43905    -36087     
- Partials       5994     7718     +1724     
Flag Coverage Δ
inttests 24.57% <100.00%> (+0.02%) ⬆️
systests 25.27% <50.00%> (+<0.01%) ⬆️
unittests 59.19% <50.00%> (+41.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...roker/service/persistent/PersistentReplicator.java 39.24% <100.00%> (+6.02%) ⬆️
...sar/broker/service/persistent/PersistentTopic.java 65.21% <100.00%> (+14.74%) ⬆️

... and 1209 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants