merlimat opened a new pull request #2387: Fixed race condition during expansion 
of concurrent open hash maps
URL: https://github.com/apache/incubator-pulsar/pull/2387
 
 
   ### Motivation
   
   Porting same fix as https://github.com/apache/bookkeeper/pull/1607 to 
correct issue reported on https://github.com/apache/bookkeeper/issues/1606.
   
   There is a race condition in the concurrent open hash maps implementation. 
The race happens when the maps gets re-hashed after the expansion and the new 
arrays are substituting the old ones.
   
   The race itself is that a thread doing a `get()` on the map is first 
checking the current capacity of the map, uses that to get the bucket and then 
tries to do optimistic read of the value in that bucket.
   
   This assumes `capacity` update is visible only after the `values` array is 
already swapped, but that is not always the case in current code.
   
   ### Changes
   
    * Use `volatile` qualifier for `capacity` and `values` arrays to ensure 
ordering of memory read is respected by compiler
    * In rehashing, update `capacity` after `values` where it was not already 
the case
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to