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

   Fixes #17908
   
   ### Motivation
   
   - `ManagedCursorImpl.setReadPosition()` will trigger cleaning of caches 
smaller than the earliest `readPosition`
   - In `ManagedLedgerFactoryImpl`, there is a scheduled task that deletes 
inactive cache data every second
   
   <strong(High light)></strong>When the `cursor` updates the `readPosition` 
and clears the outdated ledger cache concurrency, an entry's cache is 
incorrectly deleted.
   
   E.g.
   
   | `ManagedCursorImpl.setReadPosition` | 
`ManagedLedgerFactory.doCacheEviction` |
   |----|----|
   |  | check entry `1:1` has obsolete: true |
   | invalidate position `1:1` |  |
   | delete `1:1` from `EntryCache` |  |
   |  | <strong>(High light)</strong>pop first entry from `EntryCache`: 
expecting `1:1`, but really `1:2` |
   
   So entry `1:2` is incorrectly deleted.
   
   
https://github.com/apache/pulsar/blob/0c7a0d144d9e527fbd25a1d738715934fbcf38ab/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/RangeCache.java#L195-L208
   
   You can reproduce the problem by 
running`ManagedLedgerBkTest.verifyConcurrentUsage` 200~1000 times
   
   ### Modifications
   
   Use the instruction `remove(key)` instead of `popFirst()` to delete the 
target Entry
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
   - [ ] `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/poorbarcode/pulsar/pull/26
   


-- 
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