[fix][broker] BacklogMessageAge is not reset when cursor mdPosition is on an open ledger - #24915
Merged
Merged
Conversation
shibd
requested review from
Technoboy-,
codelipenghui,
coderzc and
poorbarcode
October 29, 2025 09:19
shibd
force-pushed
the
fix_backlog_age
branch
from
October 29, 2025 09:24
0589905 to
990851f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24915 +/- ##
=============================================
+ Coverage 38.45% 74.26% +35.81%
- Complexity 13176 33844 +20668
=============================================
Files 1855 1913 +58
Lines 144926 149329 +4403
Branches 16814 17334 +520
=============================================
+ Hits 55735 110905 +55170
+ Misses 81668 29574 -52094
- Partials 7523 8850 +1327
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Technoboy-
approved these changes
Oct 31, 2025
ganesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Nov 3, 2025
…s on an open ledger (apache#24915) (cherry picked from commit 54da0c8) (cherry picked from commit f97f365)
manas-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Nov 3, 2025
…s on an open ledger (apache#24915) (cherry picked from commit 54da0c8) (cherry picked from commit 60ea33a)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Nov 4, 2025
…s on an open ledger (apache#24915) (cherry picked from commit 54da0c8) (cherry picked from commit 60ea33a)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Nov 6, 2025
…s on an open ledger (apache#24915) (cherry picked from commit 54da0c8) (cherry picked from commit f97f365)
nodece
pushed a commit
to nodece/pulsar
that referenced
this pull request
Nov 12, 2025
…s on an open ledger (apache#24915) (cherry picked from commit 54da0c8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The topic stats have a metric:
oldestBacklogMessageAgeSeconds, which represents the age in seconds of the earliest backlogged message's AgeSeconds in the topic.The broker will periodically check each topic to update these metics, and it decides whether to use a precise check or an estimated check based on the
PreciseTimeBasedBacklogQuotaCheckconfiguration.When
PreciseTimeBasedBacklogQuotaCheck=false, the broker will calculate its age based on the close time of the ledger corresponding to the old position.Because the time can only be obtained when the ledger is closed, if an
oldPositionwas obtained initially, but afterward, the subscription in the topic is always caught up to the currently open ledger, then it will be skipped every time this oldPosition is updated. (The broker's default interval for updating the oldPosition is 60S, and it is very likely to hit this situation on every check.)pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Lines 3846 to 3855 in 437d9f6
This can be very confusing for users using this metric, as the subscription's MarkDeletePosition is at the latest position, but the
oldestBacklogMessageAgeSecondsmetric keeps increasing.You can run the
backlogsAgeMetricsNoPreciseWithoutBacklogQuotatest in this PR to reproduce this situation.Modifications
When
PreciseTimeBasedBacklogQuotaCheckis false, if the oldPosition is on a ledger that is currently open, we should consider that there is no oldPosition at this time and set it to -1.Verifying this change
backlogsAgeMetricsNoPreciseWithoutBacklogQuotato cover it.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: