[QFJ-338] Response to TestRequest received before the SessionState is updated Created: 19/Aug/08  Updated: 06/Oct/08  Resolved: 10/Sep/08

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.3.1
Fix Version/s: 1.3.3

Type: Bug Priority: Default
Reporter: aleksey ratushnyy Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

The problem: When a response to TestRequest is received too quickly, a false positive heartbeat timeout happens and causes disconnection.

In method quickfix.Session.next() there exists the following code:

if (state.isTestRequestNeeded())

{ generateTestRequest("TEST"); state.incrementTestRequestCounter(); getLog().onEvent("Sent test request TEST"); stateListener.onMissedHeartBeat(); }

else if (state.isHeartBeatNeeded())

{ generateHeartbeat(); }

In this code,
generateTestRequest("TEST");
sends the Test Request, a response to which can be received before line
state.incrementTestRequestCounter();
is executed.

Whenever this condition happens, there is always a false disconnect due to missed heartbeats (assuming the server does not send unsolicited heartbeats)

(why this happens:

  • quickfix.SessionState.isTestRequestNeeded() returns false up until 3*[heart beat interval]
  • quickfix.SessionState.isTimedOut() returns false only up until 2.4*[heart beat interval]
  • state.isTimedOut() returns true before state.isTestRequestNeeded(), so another TestRequest is not sent before the timeout causes the disconnection.

Note: it is not a theoretical issue, the problem does occur time to time



 Comments   
Comment by Steve Bate [ 10/Sep/08 ]

Based on my analysis, it appears it would fix the problem if I reversed the increment of the test counter and the sending of the message. Do you agree with that?

Comment by aleksey ratushnyy [ 10/Sep/08 ]

As long as you are sure it is not going to introduce any other strange race condition

Generated at Fri May 10 17:07:38 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.