Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.8.0
-
None
-
None
Description
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
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) ...
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)