oneby-wang opened a new pull request, #25117: URL: https://github.com/apache/pulsar/pull/25117
### Motivation Since `nextValidLedger:-1` is a valid `markDeletePosition`, we should move `newPosition` to `nextValidLedger:-1` to avoid cursor position and ledger inconsistency in `ManagedCursorImpl` whenever possible. PR https://github.com/apache/pulsar/pull/25087 alse made this change. ### Modifications 1. Modify `ManagedCursorImpl.asyncMarkDelete()` method, move `newPosition` to `nextValidLedger:-1` if we reach the following conditions: a. if `lastConfirmedEntry >= newPosition`, and next ledger exists, and current ledger entries are all consumed. b. if `lastConfirmedEntry < newPosition`, next ledger exists, and `newPosition == nextValidLedger:-1`. I think the previous code might have a little problem. If `newPosition == nextValidLedger:n`, n is an non-negative number, we might set new `newPosition` to `nextValidLedger:n` which is greater than `lastConfirmedEntry`. https://github.com/apache/pulsar/blob/ab65faa12ab7279a726411152af44d81b6a6704b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L2184-L2195 And snapshot positions into a local variable to avoid race condition. 2. Add `testAsyncMarkDeleteMoveToNextLedgerInNonRolloverScenario`, `testAsyncMarkDeleteMayMoveToNextLedgerInRolloverScenario`, `testAsyncMarkDeleteMoveToNextLedgerOneByOne`, `testAsyncMarkDeleteNextLedgerMinusOneEntryIdPosition` tests in `ManagedCursorImpl` to verify the code change. 3. Fix tests due to this PR's code change. 4. Fix some flaky tests introduced by PR https://github.com/apache/pulsar/pull/25087. ### Verifying this change - [x] Make sure that the change passes the CI checks. ### 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: https://github.com/oneby-wang/pulsar/pull/19 -- 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]
