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

[improve][broker] Decouple pulsar_storage_backlog_age_seconds metric with backlogQuota check #23619

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shibd
Copy link
Member

@shibd shibd commented Nov 21, 2024

Motivation

#21709 introduced a valuable metric: pulsar_storage_backlog_age_seconds, but it only updates when a topic has the message_age backlog quota policy.

Modifications

  • Decouple pulsar_storage_backlog_age_seconds metric from backlogQuota policy
  • For now, the backlogQuotaChecker is also used to periodically update the pulsar_storage_backlog_age_seconds metric, regardless of whether the topic has a backlog quota policy.

Verifying this change

  • Add backlogsAgeMetricsNoPreciseWithoutBacklogQuota and backlogsAgeMetricsPreciseWithoutBacklogQuota to cover this change.

Documentation

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

Matching PR in forked repository

PR in forked repository:

@shibd shibd added type/refactor Code or documentation refactors. e.g. refactor code structure or methods to improve code readability ready-to-test labels Nov 21, 2024
@shibd shibd self-assigned this Nov 21, 2024
@github-actions github-actions bot added doc-label-missing doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Nov 21, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 84.41558% with 12 lines in your changes missing coverage. Please review.

Project coverage is 74.42%. Comparing base (bbc6224) to head (e2a102f).
Report is 746 commits behind head on master.

Files with missing lines Patch % Lines
...sar/broker/service/persistent/PersistentTopic.java 83.60% 8 Missing and 2 partials ⚠️
...rg/apache/pulsar/broker/service/BrokerService.java 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23619      +/-   ##
============================================
+ Coverage     73.57%   74.42%   +0.85%     
- Complexity    32624    35003    +2379     
============================================
  Files          1877     1944      +67     
  Lines        139502   147136    +7634     
  Branches      15299    16224     +925     
============================================
+ Hits         102638   109512    +6874     
- Misses        28908    29184     +276     
- Partials       7956     8440     +484     
Flag Coverage Δ
inttests 27.43% <35.06%> (+2.85%) ⬆️
systests 24.42% <40.25%> (+0.09%) ⬆️
unittests 73.80% <84.41%> (+0.95%) ⬆️

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

Files with missing lines Coverage Δ
.../pulsar/broker/service/persistent/SystemTopic.java 84.21% <ø> (+4.21%) ⬆️
...rg/apache/pulsar/broker/service/BrokerService.java 84.14% <87.50%> (+3.36%) ⬆️
...sar/broker/service/persistent/PersistentTopic.java 80.13% <83.60%> (+1.67%) ⬆️

... and 663 files with indirect coverage changes

---- 🚨 Try these New Features:

@shibd shibd changed the title [improve][broker] Decouple pulsar_storage_backlog_age_seconds metric from backlogQuota policy [improve][broker] Decouple pulsar_storage_backlog_age_seconds metric with backlogQuota check Nov 21, 2024
}
return CompletableFuture.completedFuture(false);
return CompletableFuture.completedFuture(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am considering whether the value of the metric will be fine in the following case:

  • ledgers: [1:0~1:99, 2:0~2:99]
  • create a cursor s1 at 1:0
  • the value of pulsar_storage_backlog_age_seconds relates to 1:0
  • unsubscribe s1
  • the value will be never updated anymore, in other words, it always relates to 1:0


boolean expired = MessageImpl.isEntryExpired(backlogQuotaLimitInSecond, entryTimestamp);
if (log.isDebugEnabled()) {
log.debug("[{}] Time based backlog quota check. Oldest unacked entry read from BK. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log needed?

if (oldestPositionInfo == null) {
return CompletableFuture.completedFuture(false);
}
if (!hasBacklogs(brokerService.pulsar().getConfiguration().isPreciseTimeBasedBacklogQuotaCheck())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have checked it in the method checkTimeBacklogExceeded [see pic below], can we skip to check it again here?

Screenshot 2024-11-27 at 17 54 07

}
CompletableFuture<Boolean> future = new CompletableFuture<>();
CompletableFuture<Void> future = new CompletableFuture<>();
// Check if first unconsumed message(first message after mark delete position)
// for slowest cursor's has expired.
Position position = ledger.getNextValidPosition(oldestMarkDeletePosition);
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this position be x:-1? If yes, it may cause an EntryNotExists error. Could you add a test for this scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test type/refactor Code or documentation refactors. e.g. refactor code structure or methods to improve code readability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants