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

   Fix #24831
   
   ### Motivation
   
   The test ManagedCursorConcurrencyTest.testConcurrentReadOfSameEntry is 
flaky. In that case, the entries don't contain any message metadata. The broker 
cache will attempt to parse the message metadata each time the entry is cached. 
This results in a race condition since peekMessageMetadata changes the 
readerIndex of the cached ByteBuf while another thread is making a retained 
duplicate of the cached ByteBuf. Thanks for @pdolif for the analysis of the 
problem. It was helpful in locating the issue.
   
   ### Modifications
   
   - increase invocation count and concurrency in the 
ManagedCursorConcurrencyTest.testConcurrentReadOfSameEntry test to reproduce 
the issue more often
   - eliminate race conditions in 
org.apache.bookkeeper.mledger.impl.EntryImpl#initializeMessageMetadataIfNeeded
   - eliminate race conditions in 
org.apache.bookkeeper.mledger.impl.cache.RangeCacheEntryWrapper#getValueInternal
   - copy MessageMetadata from the entry that is inserted into the cache. This 
optimization was missing.
   
   ### 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 -->


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