[QFJ-645] Deadlock between message sending and reset due to message reception on Session and senderMsgSeqNumLock Created: 27/Oct/11 Updated: 08/Apr/14 Resolved: 31/Jul/12 |
|
| Status: | Resolved |
| Project: | QuickFIX/J |
| Component/s: | Engine |
| Affects Version/s: | 1.5.0, 1.5.1 |
| Fix Version/s: | 1.5.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | marc sperisen | Assignee: | Christoph John |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | deadlock | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
Deadlock arises between the following threads: Thread1:
-> Thread1 is sending a message: it first acquires the lock senderMsgSeqNumLock and then tries to acquire a lock on the session instance Thread2:
-> Thread2: while processing an incoming message, the engine notices that it is in a new session time interval (StartTime/EndTime) and therefore a MsqSeqNum reset is started. |
| Comments |
| Comment by Peter Clarke [ 12/Jan/12 ] |
|
Hi My solution to this was to remove the synchronized keyword from the Session.reset function. I've also attached a unit test we have to check for the issue. Pete |
| Comment by John [ 17/Jan/12 ] |
|
had this one too, but I haven't changed the library so I synchronized on the "Session" (=> so locks are taken in the same order). |
| Comment by John [ 02/Feb/12 ] |
|
Erratum on the preceding comment. Peter's was solution was the best one from the beggining and my workarround is not that good ;o) I just put the code I used for the "reset" method : quickfix.Session public void reset() throws IOException { if (!resetting.compareAndSet(false, true)) { return; } try { if (hasResponder()) { if (application != null && application instanceof ApplicationExtended) { ((ApplicationExtended) application).onBeforeSessionReset(sessionID); } generateLogout(); disconnect("Session reset", false); } resetState(); } finally { resetting.set(false); } } |
| Comment by Christoph John [ 31/Jul/12 ] |
|
Peter and John, |