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

   ### Motivation
   
   If we delete the ledger file from the bookkeeper,  we could open the ledger 
but will read fail.   Then if we restart the broker server to trigger 
ManagedLedgerImpl initializes,  the `AppendIndexMetadataInterceptor` will try 
to read the LAC position to recovery the index, which will cause the topic 
creating fail, see line425
   
   
https://github.com/apache/pulsar/blob/cb306c8e6c5da3a05ea312a5e5746eb178d9ab10/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L421-L427
   
   To fix it , we should do the same action as line434~line435 if 
`BKNoSuchLedgerExistsException` thrown.
   
   
https://github.com/apache/pulsar/blob/cb306c8e6c5da3a05ea312a5e5746eb178d9ab10/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L432-L436
   
   ### Modifications
   
   Removing the ledger from `ManagedLedgerImpl` and call 
`initializeBookKeeper()` if  
`managedLedgerInterceptor.onManagedLedgerLastLedgerInitialize` throws 
`BKNoSuchLedgerExistsException`,
   instead of callback fail.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   - Add UT 
`org.apache.pulsar.broker.service.PersistentTopicTest#testLastEntryReadErrorWhenInitWithManagedLedgerInterceptor`
   
   
   
   ### 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]

Reply via email to