poorbarcode opened a new pull request, #21248:
URL: https://github.com/apache/pulsar/pull/21248

   ### Motivation
   
   After trimming ledgers, the variable `lastConfirmedEntry` of the managed 
ledger might rely on a deleted ledger(the latest ledger which contains data).
   
   There is a bug that makes pulsar allow users to set the start read position 
to an unexisting ledger or a deleted ledger when creating a subscription. This 
makes the `backlog` and `markDeletedPosition` wrong. 
   
   See: 
https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L3630-L3654
   
   ```java
   public boolean isValidPosition(PositionImpl position) {
      ...
      ...
      ...
       } else if (position.getLedgerId() == lastConfirmedEntry.getLedgerId()) {
           return position.getEntryId() <= (lastConfirmedEntry.getEntryId() + 
1);
       } else {
      ...
      ...
      ...
   }
   ``` 
   
   ### Modifications
   
   Fix the bug.
   
   
   ### 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]

Reply via email to