[QFJ-634]  SequenceReset Fail Created: 22/Sep/11  Updated: 15/Nov/12  Resolved: 08/Oct/11

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.5.1
Fix Version/s: 1.5.2

Type: Bug Priority: Major
Reporter: Eric Deshayes Assignee: Eric Deshayes
Resolution: Fixed Votes: 2
Labels: None


 Description   

From Edward Lee:

Hello,

I've upgraded to QuickFix/J 1.5.1 recently.
However, I encountered an issue regarding the SequenceReset and
synchronziation with other FIX session. I found that the QuickFix cannot
handle more that one SequenceReset when sending out one ResendRequest.

Here is the scenario,

At first, the FIX connection is synchronized and let say the incoming
message seqnum and outgoing message seqnum is both 100.
Now, when I reset both in and out message seqnum to 1. Then, out of sync
happened.
At this moment, I reset the outgoing message seqnum to 100 again.
Then, QuickFix sent out a resendRequest to request message 1 to 100 as it
received a logon message of message seqnum 100.
And then, the counterParty start to resend the message and the sequence is
like below

1. SequenceReset to 31
2. 10 NewOrderSingle
3. SequenceReset to 100

What I can see the behavior of the QuickFix is that it cannot process the
first SequenceReset message and hence, the incoming message seqnum is
still remaining not synchronized.

After checking the source code, I found that the issue is in the
nextSequenceReset method in Session.java as below:

if (newSequence > getExpectedTargetNum()) {
int[] range = state.getResendRange();
if (newSequence >= range[1])

{ state.setNextTargetMsgSeqNum(newSequence); }

else if (range[2] > 0 && newSequence >= range[2])

{ state.setNextTargetMsgSeqNum(newSequence + 1); String beginString = sequenceReset.getHeader().getString(BeginString.FIELD); sendResendRequest(beginString, range[1] + 1, newSequence+1, range[1]); }

} else if (newSequence < getExpectedTargetNum()) {

getLog().onErrorEvent(
"Invalid SequenceReset: newSequence=" +
newSequence + " < expected="
+ getExpectedTargetNum());
if (resetOrDisconnectIfRequired(sequenceReset))

{ return; }
generateReject(sequenceReset,
SessionRejectReason.VALUE_IS_INCORRECT, 0);
}

When the first SequenceReset message comes, the newSequence = 30 and which
is greater than ExpectedTargetNum (i.e. 1)
Then, the range that we get is [1, 100, 0] and the problem came is the
newSequence (30) is not greater than range[1] (i.e. 100), and also
range[2] (i.e. 0) is not greater than 0.
Hence, nothing is done for the SequenceReset message.

I did make a change for the above code to:

if (newSequence > getExpectedTargetNum()) {
int[] range = state.getResendRange();
if (range[2] > 0) {
if (newSequence >= range[1]) { state.setNextTargetMsgSeqNum(newSequence); } else if(newSequence >= range[2]) { state.setNextTargetMsgSeqNum(newSequence + 1); String beginString = sequenceReset.getHeader().getString(BeginString.FIELD); sendResendRequest(beginString, range[1] + 1, newSequence+1, range[1]); }
} else { state.setNextTargetMsgSeqNum(newSequence); }
} else if (newSequence < getExpectedTargetNum()) {

getLog().onErrorEvent(
"Invalid SequenceReset: newSequence=" +
newSequence + " < expected="
+ getExpectedTargetNum());
if (resetOrDisconnectIfRequired(sequenceReset)) { return; }

generateReject(sequenceReset,
SessionRejectReason.VALUE_IS_INCORRECT, 0);
}

And now, I can successfully synchronize.

The question I have is does anyone also encounter this issue? Or did I
miss any config or setup and such that I have this issue?



 Comments   
Comment by Andrzej Hajderek [ 06/Oct/11 ]

Hi,

I have the same problem. Below is an extract from the log. The incoming Sequence Reset from 1 to 2 is not processed correctly. As result the target sequence number is not set to 2. In consequence the messages with sequence number 2 and above are queued instead of being processed:

quickfix.outgoing: 8=FIX.4.29=7235=A34=6549=AAA52=20111006-13:01:16.70156=BBB98=0108=3010=222

quickfix.incoming: 8=FIX.4.29=006835=A34=9549=BBB56=AAA52=20111006-13:01:2798=0108=3010=130

quickfix: Received logon

quickfix: MsgSeqNum too high, expecting 1 but received 95: 8=FIX.4.29=6835=A34=9549=BBB52=20111006-13:01:2756=AAA98=0108=3010=034

quickfix: Enqueued at pos 95: 8=FIX.4.29=6835=A34=9549=BBB52=20111006-13:01:2756=AAA98=0108=3010=034

quickfix.outgoing: 8=FIX.4.29=6935=234=6649=AAA52=20111006-13:01:16.90456=BBB7=116=010=061

quickfix: Sent ResendRequest FROM: 1 TO: 94

quickfix.incoming: 8=FIX.4.29=009335=434=149=BBB56=AAA43=Y52=20111006-13:01:28122=20111006-13:01:2836=2123=Y10=080

quickfix.incoming: 8=FIX.4.29=034535=8128=CCC57=DDD34=249=BBB56=AAA43=Y52=20111006-13:01:28122=20111006-12:02:1355=SMU1 17=21123141039=214=1237=NeMO-23449-131724431614738=1220=0150=2151=040=26001=LLL60=20110928-21:12:316002=HHH44=22.0200=20110922=A207=FFF167=FUT1=61A16S32-XYZ6=22.032=12442=231=22.054=175=2011092810=068

quickfix: Received SequenceReset FROM: 1 TO: 2

quickfix: MsgSeqNum too high, expecting 1 but received 2: 8=FIX.4.29=34535=834=243=Y49=BBB52=20111006-13:01:2856=AAA57=DDD122=20111006-12:02:13128=CCC1=61A16S32-XYZ6=22.014=1217=21123141020=022=A31=22.032=1237=NeMO-23449-131724431614738=1239=240=244=22.054=155=SMU1 60=20110928-21:12:3175=20110928150=2151=0167=FUT200=201109207=FFF442=26001=LLL6002=HHH10=020

quickfix.incoming: 8=FIX.4.29=036235=8128=CCC57=DDD34=349=BBB56=AAA43=Y52=20111006-13:01:28122=20111006-12:02:1355=ESU117=21185307539=214=2137=NeMO-23449-131724469749638=2120=0150=2151=040=26001=III60=20110928-21:18:536002=HHH44=24.6190476200=20110922=A207=GGG167=FUT1=0007YSXM-XYZ6=24.619047632=21442=231=24.619047654=175=2011092810=076

quickfix: Enqueued at pos 2: 8=FIX.4.29=34535=834=243=Y49=BBB52=20111006-13:01:2856=AAA57=DDD122=20111006-12:02:13128=CCC1=61A16S32-XYZ6=22.014=1217=21123141020=022=A31=22.032=1237=NeMO-23449-131724431614738=1239=240=244=22.054=155=SMU1 60=20110928-21:12:3175=20110928150=2151=0167=FUT200=201109207=FFF442=26001=LLL6002=HHH10=020

quickfix.incoming: 8=FIX.4.29=035835=8128=CCC57=EEE34=449=BBB56=AAA43=Y52=20111006-13:01:28122=20111006-12:02:1358=vvv55=ERH2 17=15554324439=214=137=BWT7-72069688681597593-09/29/201138=120=0150=2151=040=26001=JJJ60=20110929-15:55:436002=KKK44=97.96200=20120322=A207=XLIF167=FUT1=96Y05A03-XYZ6=97.9632=1442=231=97.9654=275=2011092910=114

quickfix: Already sent ResendRequest FROM: 1 TO: 94. Not sending another.

quickfix: MsgSeqNum too high, expecting 1 but received 3: 8=FIX.4.29=36235=834=343=Y49=BBB52=20111006-13:01:2856=AAA57=DDD122=20111006-12:02:13128=CCC1=0007YSXM-XYZ6=24.619047614=2117=21185307520=022=A31=24.619047632=2137=NeMO-23449-131724469749638=2139=240=244=24.619047654=155=ESU160=20110928-21:18:5375=20110928150=2151=0167=FUT200=201109207=GGG442=26001=III6002=HHH10=028

quickfix: Enqueued at pos 3: 8=FIX.4.29=36235=834=343=Y49=BBB52=20111006-13:01:2856=AAA57=DDD122=20111006-12:02:13128=CCC1=0007YSXM-XYZ6=24.619047614=2117=21185307520=022=A31=24.619047632=2137=NeMO-23449-131724469749638=2139=240=244=24.619047654=155=ESU160=20110928-21:18:5375=20110928150=2151=0167=FUT200=201109207=GGG442=26001=III6002=HHH10=028

Comment by Andrzej Hajderek [ 06/Oct/11 ]

Hi again,

I propose to change the priority to critical. The 1.5.1 release was supposed to be a bug fix release, while this bug disqualifies it as production-ready in some circumstances.

Regards,
Andrzej

Comment by Andy Malakov [ 06/Oct/11 ]

We see the same problem when talking with ULLink FIX server. Proposed patch seems to resolve this issue.

Comment by Eric Deshayes [ 08/Oct/11 ]

Committed in rev#1053

Generated at Sat Nov 23 07:20:47 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.