[ 
https://issues.apache.org/jira/browse/ARTEMIS-5874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Justin Bertram updated ARTEMIS-5874:
------------------------------------
    Description: 
A deadlock can occur when the broker services a STOMP {{DISCONNECT}} frame with 
a {{receipt}} header at the same time the corresponding connection is closed by 
the broker (e.g. due to inactivity). Here's the relevant stack-trace:
{noformat}
Found one Java-level deadlock:
=============================
"Thread-1 (activemq-netty-threads)":
  waiting to lock monitor 0x00007efe204d8f60 (object 0x000000009c8864e8, a 
java.lang.Object),
  which is held by "Thread-15"

"Thread-15":
  waiting to lock monitor 0x00007efe00001e20 (object 0x000000009c886410, a 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection),
  which is held by "Thread-1 (activemq-netty-threads)"

Java stack information for the threads listed above:
===================================================
"Thread-1 (activemq-netty-threads)":
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.destroy(StompConnection.java:225)
        - waiting to lock <0x000000009c8864e8> (a java.lang.Object)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.disconnect(StompConnection.java:522)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.disconnect(StompConnection.java:517)
        at 
org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11.replySent(StompFrameHandlerV11.java:238)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.physicalSend(StompConnection.java:649)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.send(StompProtocolManager.java:209)
        - locked <0x000000009c886410> (a 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager$1.done(StompProtocolManager.java:304)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:266)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:188)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.afterCompleteOperations(AbstractJournalStorageManager.java:355)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.sendReply(StompProtocolManager.java:290)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.sendFrame(StompConnection.java:461)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.handleFrame(StompConnection.java:431)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:162)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:308)
        at 
org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:723)
        at 
org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.channelRead(ActiveMQChannelHandler.java:73)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:266)
        at 
io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:537)
        at 
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)
        at 
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
        at 
org.apache.activemq.artemis.core.protocol.ProtocolHandler$ProtocolDecoder.channelRead(ProtocolHandler.java:187)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)
        at 
io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:799)
        at 
io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:501)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:399)
        at 
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at 
org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
"Thread-15":
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.send(StompProtocolManager.java:203)
        - waiting to lock <0x000000009c886410> (a 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager$1.done(StompProtocolManager.java:304)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:266)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:188)
        at 
org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.afterCompleteOperations(AbstractJournalStorageManager.java:355)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.sendReply(StompProtocolManager.java:290)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.sendFrame(StompConnection.java:461)
        at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.fail(StompConnection.java:262)
        - locked <0x000000009c8864e8> (a java.lang.Object)
        at 
org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.issueFailure(RemotingServiceImpl.java:622)
        at 
org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.connectionException(RemotingServiceImpl.java:648)
        at 
org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener.lambda$connectionException$0(NettyAcceptor.java:964)
        at 
org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener$$Lambda/0x00007efefc4b9fe8.run(Unknown
 Source)
        at java.lang.Thread.runWith([email protected]/Thread.java:1596)
        at java.lang.Thread.run([email protected]/Thread.java:1583)

Found 1 deadlock.{noformat}

  was:
A deadlock can occur when the broker services a STOMP {{DISCONNECT}} frame with 
a {{receipt}} header at the same time the corresponding connection is closed by 
the broker (e.g. due to inactivity). Here's the relevant stack-trace:
{noformat}

 

STOMP protocol can hit a JVM deadlock.  Here are the key details:
 * DISCONNECT frame sent to the broker on valid STOMP connection
 ** with a "receipt" header
 * At the same time, Netty reports a disconnect (call goes to 
{{{}org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.connectionException{}}})

Deadlock is reported by {{jstack}} or {{jcmd ... Thread.print.}}

The cause is 2 locks being acquired in different orders by separate threads.  
Here are the top of the calling stack for the 2 deadlocked threads:
 * at 
org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.send(StompProtocolManager.java:203)
 * at 
org.apache.activemq.artemis.core.protocol.stomp.StompConnection.destroy(StompConnection.java:225)


> Deadlock in STOMP protocol on DISCONNECT with receipt
> -----------------------------------------------------
>
>                 Key: ARTEMIS-5874
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5874
>             Project: Artemis
>          Issue Type: Bug
>          Components: STOMP
>    Affects Versions: 2.39.0
>         Environment: ActiveMQ 2.39.0
> Linux
>  
>            Reporter: Arthur Naseef
>            Assignee: Justin Bertram
>            Priority: Critical
>         Attachments: FRAME.connect, FRAME.disconnect, STACK.txt
>
>
> A deadlock can occur when the broker services a STOMP {{DISCONNECT}} frame 
> with a {{receipt}} header at the same time the corresponding connection is 
> closed by the broker (e.g. due to inactivity). Here's the relevant 
> stack-trace:
> {noformat}
> Found one Java-level deadlock:
> =============================
> "Thread-1 (activemq-netty-threads)":
>   waiting to lock monitor 0x00007efe204d8f60 (object 0x000000009c8864e8, a 
> java.lang.Object),
>   which is held by "Thread-15"
> "Thread-15":
>   waiting to lock monitor 0x00007efe00001e20 (object 0x000000009c886410, a 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection),
>   which is held by "Thread-1 (activemq-netty-threads)"
> Java stack information for the threads listed above:
> ===================================================
> "Thread-1 (activemq-netty-threads)":
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.destroy(StompConnection.java:225)
>       - waiting to lock <0x000000009c8864e8> (a java.lang.Object)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.disconnect(StompConnection.java:522)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.disconnect(StompConnection.java:517)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11.replySent(StompFrameHandlerV11.java:238)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.physicalSend(StompConnection.java:649)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.send(StompProtocolManager.java:209)
>       - locked <0x000000009c886410> (a 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager$1.done(StompProtocolManager.java:304)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:266)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:188)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.afterCompleteOperations(AbstractJournalStorageManager.java:355)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.sendReply(StompProtocolManager.java:290)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.sendFrame(StompConnection.java:461)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.handleFrame(StompConnection.java:431)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:162)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:308)
>       at 
> org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:723)
>       at 
> org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.channelRead(ActiveMQChannelHandler.java:73)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
>       at 
> io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:266)
>       at 
> io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:537)
>       at 
> io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)
>       at 
> io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
>       at 
> org.apache.activemq.artemis.core.protocol.ProtocolHandler$ProtocolDecoder.channelRead(ProtocolHandler.java:187)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
>       at 
> io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
>       at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
>       at 
> io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)
>       at 
> io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:799)
>       at 
> io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:501)
>       at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:399)
>       at 
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
>       at 
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>       at 
> org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
> "Thread-15":
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.send(StompProtocolManager.java:203)
>       - waiting to lock <0x000000009c886410> (a 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager$1.done(StompProtocolManager.java:304)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:266)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl.executeOnCompletion(OperationContextImpl.java:188)
>       at 
> org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.afterCompleteOperations(AbstractJournalStorageManager.java:355)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager.sendReply(StompProtocolManager.java:290)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.sendFrame(StompConnection.java:461)
>       at 
> org.apache.activemq.artemis.core.protocol.stomp.StompConnection.fail(StompConnection.java:262)
>       - locked <0x000000009c8864e8> (a java.lang.Object)
>       at 
> org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.issueFailure(RemotingServiceImpl.java:622)
>       at 
> org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.connectionException(RemotingServiceImpl.java:648)
>       at 
> org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener.lambda$connectionException$0(NettyAcceptor.java:964)
>       at 
> org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener$$Lambda/0x00007efefc4b9fe8.run(Unknown
>  Source)
>       at java.lang.Thread.runWith([email protected]/Thread.java:1596)
>       at java.lang.Thread.run([email protected]/Thread.java:1583)
> Found 1 deadlock.{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to