GitHub user wy96f opened a pull request:
https://github.com/apache/activemq-artemis/pull/1851
fix npe bug while getting element in the process of rehash
Hi, we found a bug in ConcurrentLongHashMap, as follows:
12:32:31,000 WARN
[org.apache.activemq.artemis.core.replication.ReplicationEndpoint] 295:
java.lang.ArrayIndexOutOfBoundsException: 295
at
org.apache.activemq.artemis.utils.collections.ConcurrentLongHashMap$Section.get(ConcurrentLongHashMap.java:230)
[artemis-commons-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.utils.collections.ConcurrentLongHashMap.get(ConcurrentLongHashMap.java:117)
[artemis-commons-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.journal.impl.JournalImpl.appendCommitRecord(JournalImpl.java:1185)
[artemis-journal-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.journal.impl.JournalBase.appendCommitRecord(JournalBase.java:69)
[artemis-journal-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.journal.impl.JournalImpl.appendCommitRecord(JournalImpl.java:91)
[artemis-journal-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.replication.ReplicationEndpoint.handleCommitRollback(ReplicationEndpoint.java:635)
[artemis-server-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.replication.ReplicationEndpoint.handlePacket(ReplicationEndpoint.java:191)
[artemis-server-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.handlePacket(ChannelImpl.java:638)
[artemis-core-client-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.doBufferReceived(RemotingConnectionImpl.java:392)
[artemis-core-client-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:374)
[artemis-core-client-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$DelegatingBufferHandler.bufferReceived(ClientSessionFactoryImpl.java:1144)
[artemis-core-client-2.4.0.jar:2.4.0]
at
org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.channelRead(ActiveMQChannelHandler.java:68)
[artemis-core-client-2.4.0.jar:2.4.0]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:797)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:404)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:304)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at
io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
[netty-all-4.1.16.Final.jar:4.1.16.Final]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
The get thread saw doubled capacity first and at the moment values had not
been assigned new values, so npe occurred. We should assign capacity after the
keys and values. The volatile modifier would be needed to generate store
barrier to make sure keys/values data are visible to other threads before the
capacity is.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/wy96f/activemq-artemis
concurrent_hash_long_map
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/activemq-artemis/pull/1851.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1851
----
commit ca6548d1739d4dba1e7114742ddf06a2a84aae3a
Author: yang wei <wy96fyw@...>
Date: 2018-02-05T10:12:18Z
fix npe bug while getting element in the process of rehash
----
---