-
Notifications
You must be signed in to change notification settings - Fork 964
[fix] Fix ConcurrentLongHashMap concurrency issue #4317
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
Conversation
get|
It looks other Concurrent containers has the same issue, I'll create PRs to fix them one by one. |
|
I created an issue for tracking it #4318 |
|
BTW, the key point is int capacity = this.capacity;
bucket = signSafeMod(bucket, capacity);and // First try optimistic locking
long storedKey = keys[bucket];
V storedValue = values[bucket];not an atomic operation. If |
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting the issue and starting the work to fix this issue.
Catching the exception would be the preferred solution since there's no point of using a StampedLock unless optimistic locking is used.
I think that we had this same bug discussed years ago, but for some reason we didn't fix this.
|
Found the discussion from the past: apache/pulsar#18390 (comment) . @thetumbled had originally made a PR to catch IndexOutOfBoundsException, which I think is the correct solution. |
|
I have created this pr to fix the issue in bookkeeper: #4066, can we move forward with it? @lhotari @hangc0276 @eolivelli @wenbingshen @zymap @shoothzj @horizonzy |
|
Let's close this PR and continue with #4066 |
|
Good! Let's continue with #4066 |
Descriptions of the changes in this PR:
Motivation
Fix ConcurrentLongHashMap can be ArrayIndexOutBound when call
getChanges
(Describe: what changes you have made)
Master Issue: #4316