Skip to content

ConcurrentLongHashMap may throw an ArrayIndexOutOfBoundsException #4684

@keyboardbobo

Description

@keyboardbobo

@lhotari @thetumbled please take a look at this issue.

BUG REPORT
Due to previous issues with EBADREQ (bookie error : Unexpected exception while writing ), I cherry-pick the PR: https://github.com/apache/bookkeeper/pull/4066, the org.apache.bookkeeper.util.collections.ConcurrentLongHashMap is almost the latest version, v4.17, but the but the error still occurred

Describe the bug

2025-11-18 05:41:50.0605 [BookieWriteThreadPool-OrderedExecutor-7-0] ERROR org.apache.bookkeeper.proto.WriteEntryProcessor - Unexpected exception while writing 165663447@90916 : 1190
java.lang.ArrayIndexOutOfBoundsException: 1190
at org.apache.bookkeeper.util.collections.ConcurrentLongHashMap$Section.get(ConcurrentLongHashMap.java:346) ~[bookkeeper-server-4.14_vivo-1.5.3-20251117.092459-17.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-20251117.092459-17.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.bookie.Bookie.addEntryInternal(Bookie.java:1336) ~[bookkeeper-server-4.14_vivo-1.5.3-20251117.092459-17.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.bookie.Bookie.addEntry(Bookie.java:1465) ~[bookkeeper-server-4.14_vivo-1.5.3-20251117.092459-17.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.proto.WriteEntryProcessor.processPacket(WriteEntryProcessor.java:81) [bookkeeper-server-4.14_vivo-1.5.3-20251117.092459-17.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.proto.PacketProcessorBase.safeRun(PacketProcessorBase.java:175) [bookkeeper-server-4.14_vivo-1.5.3-20251117.092459-17.jar:4.14_vivo-1.5.3-SNAPSHOT]
at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) [org.apache.bookkeeper-bookkeeper-common-4.14_vivo-1.5.3-20251111.081949-12.jar:4.14_vivo-1.5.3-SNAPSHOT]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_192]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_192]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.74.Final.jar:4.1.74.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]

To Reproduce
I performed a load test at 100,000 TPS per machine, and the problem only occurred once every one or two days, indicating a relatively low probability of occurrence.

Expected behavior
no error

Screenshots

Image

Additional context

private final ConcurrentLongHashMap<byte[]> masterKeyCache =
        ConcurrentLongHashMap.<byte[]>newBuilder().autoShrink(true).build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions