You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/08/16 06:04:10 UTC

[GitHub] merlimat opened a new pull request #1607: Issue 1606: Fixed race condition during expansion of concurrent open hash maps

merlimat opened a new pull request #1607: Issue 1606: Fixed race condition during expansion of concurrent open hash maps
URL: https://github.com/apache/bookkeeper/pull/1607
 
 
   ### Motivation
   
   As reported in #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`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services