Ludovic Pollet created AMQNET-830:
-------------------------------------

             Summary: Deadlock when closing session and connection
                 Key: AMQNET-830
                 URL: https://issues.apache.org/jira/browse/AMQNET-830
             Project: ActiveMQ .Net
          Issue Type: Bug
          Components: OpenWire
    Affects Versions: 1.8.0
            Reporter: Ludovic Pollet


Closing a session in a thread and the connection in another thread will collide 
and yield to a deadlock.

The thread (18) which closes the connection :
  * owns the lock sessions.SyncRoot
  * wants the session own lock : mylock 
The thread (20) which closes the session:
  * own session's mylock
  * wants sessions.SyncRoot to remove itself from sessions
 
{code:java}
Thread 18:
    [Deadlocked, double-click or press enter to view all thread stacks] 
(Unknown Source:0)
    [Waiting on lock owned by Thread 20] (Unknown Source:0)
    Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Session.Shutdown() (Unknown 
Source:0)
    Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Connection.Close() (Unknown 
Source:0)
    ...
    [Native to Managed Transition] (Unknown Source:0)

Thread 20:
    [Deadlocked, double-click or press enter to view all thread stacks] 
(Unknown Source:0)
    [Waiting on lock owned by Thread 18] (Unknown Source:0)
    
System.Private.CoreLib.dll!System.Collections.ArrayList.SyncArrayList.Remove(object
 value) (Unknown Source:0)
    
Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Connection.RemoveSession(Apache.NMS.ActiveMQ.Session
 session) (Unknown Source:0)
    Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Session.Shutdown() (Unknown 
Source:0)
    Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Session.DoClose() (Unknown 
Source:0)
    Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Session.Close() (Unknown 
Source:0)
    ...
{code}
 

I can only test in 1.8.0 version. I didn't see any relevant change in the 
locking scheme since the 1.8.0 version so I assume this bug is still present in 
more recent releases

I guess sessions.SyncRoot could be released before calling Shutdown on the 
session (by copying the content of sessions)




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

Reply via email to