Skip to content

Conversation

@thetumbled
Copy link
Member

@thetumbled thetumbled commented Sep 1, 2023

Motivation

This is the bug fix simillar to Pulsar. refer to: apache/pulsar#18390.

Changes

Fix bugs in:

ConcurrentLongHashMap
ConcurrentLongHashSet
ConcurrentLongLongHashMap
ConcurrentLongLongPairHashMap
ConcurrentOpenHashMap
ConcurrentOpenHashSet

@thetumbled
Copy link
Member Author

thetumbled commented Sep 18, 2023

Could you help to reviw this PR? @eolivelli @sijie @hangc0276 @zymap
Thanks.

@thetumbled
Copy link
Member Author

Could you help to reviw this PR? @eolivelli @dlg99 @hangc0276 @nicoloboschi @shoothzj @zymap @wenbingshen
This bug could happen when the concurrent data structure shrink it's capacity.

@thetumbled
Copy link
Member Author

I find that the same concurrency problem is reported in bookkeeper #4316, it is time to merge this fix into the bookkeeper.
PTAL, thanks. @lhotari @hangc0276 @eolivelli @wenbingshen @zymap @shoothzj @horizonzy

Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thank you!

@dlg99 dlg99 changed the title Fix ArrayIndexOut0fBoundsException caused by optimistic lock [fix] Fix ArrayIndexOut0fBoundsException caused by optimistic lock Apr 28, 2024
@dlg99
Copy link
Contributor

dlg99 commented Apr 28, 2024

retest this please

@eolivelli
Copy link
Contributor

closing/reopening to trigger CI

@eolivelli eolivelli closed this Apr 28, 2024
@eolivelli eolivelli reopened this Apr 28, 2024
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

thanks

@dlg99
Copy link
Contributor

dlg99 commented Apr 28, 2024

Please fix the checkstyle


[INFO] There are 6 errors reported by Checkstyle 9.3 with buildtools/src/main/resources/bookkeeper/checkstyle.xml ruleset.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMapTest.java:[224,29] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongPairHashMapTest.java:[41,1] (imports) ImportOrder: Extra separation in import group before 'org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap.LongPair'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashSetTest.java:[40,1] (imports) ImportOrder: Extra separation in import group before 'org.junit.Test'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMapTest.java:[42,1] (imports) ImportOrder: Extra separation in import group before 'org.apache.bookkeeper.util.collections.ConcurrentLongLongHashMap.LongLongFunction'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMapTest.java:[220,32] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashSetTest.java:[39,1] (imports) ImportOrder: Extra separation in import group before 'org.junit.Test'

@thetumbled
Copy link
Member Author

Please fix the checkstyle


[INFO] There are 6 errors reported by Checkstyle 9.3 with buildtools/src/main/resources/bookkeeper/checkstyle.xml ruleset.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMapTest.java:[224,29] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongPairHashMapTest.java:[41,1] (imports) ImportOrder: Extra separation in import group before 'org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap.LongPair'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashSetTest.java:[40,1] (imports) ImportOrder: Extra separation in import group before 'org.junit.Test'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMapTest.java:[42,1] (imports) ImportOrder: Extra separation in import group before 'org.apache.bookkeeper.util.collections.ConcurrentLongLongHashMap.LongLongFunction'
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMapTest.java:[220,32] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Error:  src/test/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashSetTest.java:[39,1] (imports) ImportOrder: Extra separation in import group before 'org.junit.Test'

fixed, please help to re-trigger the CI, thanks.

@dlg99 dlg99 merged commit e4faf25 into apache:master Apr 28, 2024
dlg99 pushed a commit to datastax/bookkeeper that referenced this pull request Apr 29, 2024
@lhotari
Copy link
Member

lhotari commented Apr 30, 2024

@dlg99 @eolivelli Please cherry-pick this PR to branch-4.16.

@hezhangjian
Copy link
Member

@lhotari done

@keyboardbobo
Copy link

keyboardbobo commented Nov 17, 2025

java.lang.ArrayIndexOutOfBoundsException: 1774
at org.apache.bookkeeper.util.collections.ConcurrentLongHashMap$Section.get(ConcurrentLongHashMap.java:346) ~[bookkeeper-server-4.14_vivo-1.5.3-20251114.065856-16.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.util.collections.ConcurrentLongHashMap.get(ConcurrentLongHashMap.java:206) ~[bookkeeper-server-4.14_vivo-1.5.3-20251114.065856-16.jar:4.14_vivo-1.5.3-SNAPSHOT]

@thetumbled I cherry-pick this PR, but the error still occurred, although the probability of it appearing was greatly reduced. Should we catch the exception and perform lock upgrade when accessing long storedKey = keys[bucket] out of bounds?

@lhotari
Copy link
Member

lhotari commented Nov 17, 2025

java.lang.ArrayIndexOutOfBoundsException: 1774
at org.apache.bookkeeper.util.collections.ConcurrentLongHashMap$Section.get(ConcurrentLongHashMap.java:346) ~[bookkeeper-server-4.14_vivo-1.5.3-20251114.065856-16.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.util.collections.ConcurrentLongHashMap.get(ConcurrentLongHashMap.java:206) ~[bookkeeper-server-4.14_vivo-1.5.3-20251114.065856-16.jar:4.14_vivo-1.5.3-SNAPSHOT]

@thetumbled I cherry-pick this PR, but the error still occurred, although the probability of it appearing was greatly reduced. Should we catch the exception and perform lock upgrade when accessing long storedKey = keys[bucket] out of bounds?

@keyboardbobo please report a new issue and share your stack trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants