-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArrayIndexOutOfBoundsException on ConcurrentLongHashMap #1606
Milestone
Comments
merlimat
added a commit
that referenced
this issue
Aug 16, 2018
… hash maps ### 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` Author: Matteo Merli <mmerli@apache.org> Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org> This closes #1607 from merlimat/fix-concurrent-maps, closes #1606 (cherry picked from commit a7e66e1) Signed-off-by: Matteo Merli <mmerli@apache.org>
merlimat
added a commit
that referenced
this issue
Aug 16, 2018
… hash maps ### 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` Author: Matteo Merli <mmerli@apache.org> Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org> This closes #1607 from merlimat/fix-concurrent-maps, closes #1606 (cherry picked from commit a7e66e1) Signed-off-by: Matteo Merli <mmerli@apache.org>
sijie
pushed a commit
to apache/pulsar
that referenced
this issue
Aug 17, 2018
…2387) ### Motivation Porting same fix as apache/bookkeeper#1607 to correct issue reported on apache/bookkeeper#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
sijie
pushed a commit
to apache/pulsar
that referenced
this issue
Aug 27, 2018
…2387) ### Motivation Porting same fix as apache/bookkeeper#1607 to correct issue reported on apache/bookkeeper#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
reddycharan
pushed a commit
to reddycharan/bookkeeper
that referenced
this issue
Oct 17, 2018
…t open hash maps ### Motivation As reported in apache#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` Author: Matteo Merli <mmerli@apache.org> Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org> This closes apache#1607 from merlimat/fix-concurrent-maps, closes apache#1606 (cherry picked from commit a7e66e1) Signed-off-by: Matteo Merli <mmerli@apache.org> (cherry picked from commit 36edaca) Signed-off-by: JV Jujjuri <vjujjuri@salesforce.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
The text was updated successfully, but these errors were encountered: