Jason918 commented on PR #16125:
URL: https://github.com/apache/pulsar/pull/16125#issuecomment-1188858989

   
   
   
   > `data` array elements are mutated and read with 2 different locks in the 
methods in `GrowableArrayBlockingQueue` class. For example, `poll` is guarded 
by `headLock` and `put` is guarded by `tailLock`. I don't see how that could be 
thread safe. There's a related StackOverflow answer 
https://stackoverflow.com/a/8978397 which states:
   > 
   > > "This means that you can safely write to two different indexes 
concurrently. However you need to synchronize a write/read to the same index if 
you want to make sure the consumer thread sees the last value written by the 
producer thread."
   
   @lhotari OK, I get your point. The race condition refers to array elements. 
This make sense. 
   I can try to create a bad case for this. 


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