shibd opened a new pull request, #24915: URL: https://github.com/apache/pulsar/pull/24915
### 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 `PreciseTimeBasedBacklogQuotaCheck` configuration. 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 `oldPosition` was 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.) https://github.com/apache/pulsar/blob/437d9f6a3ccfdfd327ac032c298728fcc43fc263/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L3846-L3855 This can be very confusing for users using this metric, as the subscription's MarkDeletePosition is at the latest position, but the `oldestBacklogMessageAgeSeconds` metric keeps increasing. You can run the `backlogsAgeMetricsNoPreciseWithoutBacklogQuota` test in this PR to reproduce this situation. ### Modifications When `PreciseTimeBasedBacklogQuotaCheck` is 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 - Added `backlogsAgeMetricsNoPreciseWithoutBacklogQuota` to cover it. ### Does this pull request potentially affect one of the following parts: <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: <!-- ENTER URL HERE --> <!-- After opening this PR, the build in apache/pulsar will fail and instructions will be provided for opening a PR in the PR author's forked repository. apache/pulsar pull requests should be first tested in your own fork since the apache/pulsar CI based on GitHub Actions has constrained resources and quota. GitHub Actions provides separate quota for pull requests that are executed in a forked repository. The tests will be run in the forked repository until all PR review comments have been handled, the tests pass and the PR is approved by a reviewer. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
