poorbarcode opened a new pull request, #25047:
URL: https://github.com/apache/pulsar/pull/25047
### Motivation
**Background**
By default, the backlog of a subscription is got by `{num of entries
published} - {num of entries acknowleged}`
- `num of entries published`: `ManagedLedger.entriesAddedCounter`
- `num of entries acknowleged`: `ManagedLedger.messagesConsumedCounter`
How it being modified when calling `reset curosr` or `seek` or `cumulative
acknowledge`
- Calculate entries between `{original md-position}` and `{target
md-position}`, gets `counter-1`. If `{target md-position}` is smaller than
`{original md-position}`, the result of `counter-1` will be negative.
- Calculate entries that are before `{target md-position}` and were
acknowledged before calling `reset curosr`, gets `counter-2`. If `{target
md-position}` is smaller than `{original md-position}`, the result of
`counter-2` will be `0`.
- Let `cursor.messagesConsumedCounter` add `{counter-1} - {counter-2}`
**Issue 1**: clears individual acknowledge status before calculate how many
entries acked.
1. Call `reset cursor` or `seek` or `cumulative acknowledge`
1. Broker moves `md-position` to the target.
1. Broker clears `cursor. individualDeletedMessages`, see
https://github.com/apache/pulsar/blob/v4.1.2/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L2315-L2316
1. Broker calculate how many entries that were acked, see Background for the
implementation.
1. Issue: the items that mantained by `cursor. individualDeletedMessages`
has been removed at setp 3.
a. The step 4 can not get a correct `{counter-2}`, which is described at
the Background.
**Issue 2**: `reset curosr` or `seek` forgtes to reduce the counter that
acknowledged messages
1. Status: `md-positiin : 3:5`, `cursor. individualDeletedMessages`: `[3:10
~ 3:11]`
2. Call `reset cursor` or `seek` to `3: 5`, which is the same as before.
3. Broker clears `cursor. individualDeletedMessages`, but forget to reduce
`cursor.messagesConsumedCounter` that `cursor. individualDeletedMessages`:
`[3:10 ~ 3:11]` increased.
### Modifications
- fix bugs
### 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: x
--
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]