-
Notifications
You must be signed in to change notification settings - Fork 666
Fix incorrect resend of session-level messages with ForceResendWhenCorruptedStore
#1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
4
commits into
master
Choose a base branch
from
copilot/fix-resend-session-messages
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bcd2e1f
Initial plan
Copilot e9a954b
Fix session-level message resend issue when ForceResendWhenCorruptedS…
Copilot 5423d5a
Improve code comment clarity for admin message resend logic
Copilot e180fa4
Address review feedback: restore Heartbeat logic and use session-spec…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2352,13 +2352,10 @@ private void resendMessages(Message receivedMessage, int beginSeqNo, int endSeqN | |
| state.get(beginSeqNo, endSeqNo, messages); | ||
| } catch (final IOException e) { | ||
| if (forceResendWhenCorruptedStore) { | ||
| LOG.error("Cannot read messages from stores, resend HeartBeats", e); | ||
| LOG.error("Cannot read messages from stores, will gap fill over missing messages", e); | ||
| // Add null placeholders for corrupted messages instead of fake Heartbeats | ||
| for (int i = beginSeqNo; i < endSeqNo; i++) { | ||
| final Message heartbeat = messageFactory.create(sessionID.getBeginString(), | ||
| MsgType.HEARTBEAT); | ||
| initializeHeader(heartbeat.getHeader()); | ||
| heartbeat.getHeader().setInt(MsgSeqNum.FIELD, i); | ||
| messages.add(heartbeat.toString()); | ||
| messages.add(null); | ||
| } | ||
| } else { | ||
| throw e; | ||
|
|
@@ -2375,6 +2372,15 @@ private void resendMessages(Message receivedMessage, int beginSeqNo, int endSeqN | |
| final Message msg; | ||
| try { | ||
| // QFJ-626 | ||
| // Handle null placeholders from corrupted store | ||
| if (message == null) { | ||
| // Mark for gap fill | ||
| if (begin == 0) { | ||
| begin = current; | ||
| } | ||
| current++; | ||
| continue; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot this can be removed also.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in e180fa4. Removed the null placeholder handling code. |
||
| msg = parseMessage(message); | ||
| msgSeqNum = msg.getHeader().getInt(MsgSeqNum.FIELD); | ||
| } catch (final Exception e) { | ||
|
|
@@ -2391,11 +2397,33 @@ private void resendMessages(Message receivedMessage, int beginSeqNo, int endSeqN | |
|
|
||
| final String msgType = msg.getHeader().getString(MsgType.FIELD); | ||
|
|
||
| if (MessageUtils.isAdminMessage(msgType) && !forceResendWhenCorruptedStore) { | ||
| if (begin == 0) { | ||
| begin = msgSeqNum; | ||
| // Check if message is an admin message | ||
| // According to FIX spec, only Reject messages should be resent among admin messages | ||
| if (MessageUtils.isAdminMessage(msgType)) { | ||
| if (MsgType.REJECT.equals(msgType)) { | ||
| // Reject messages should be resent | ||
| // Note: We don't call resendApproved() here to avoid calling toApp() on admin messages | ||
| initializeResendFields(msg); | ||
| if (begin != 0) { | ||
| generateSequenceReset(receivedMessage, begin, msgSeqNum); | ||
| } | ||
| getLog().onEvent("Resending Reject message: " + msgSeqNum); | ||
| boolean sent = send(msg.toString()); | ||
| if (!sent) { | ||
| // Abort resend operation immediately - don't send any more messages | ||
| getLog().onWarnEvent("Resending messages aborted."); | ||
| return; | ||
| } | ||
| begin = 0; | ||
| appMessageJustSent = true; | ||
| } else { | ||
| // Other admin messages should NOT be resent, mark for gap fill | ||
| if (begin == 0) { | ||
| begin = msgSeqNum; | ||
| } | ||
| } | ||
| } else { | ||
| // Application message - resend normally | ||
| initializeResendFields(msg); | ||
| if (resendApproved(msg)) { | ||
| if (begin != 0) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please roll back these changes and restore the former logic that puts Heartbeats into the messages list.
Moreover, use the session-specific log instead of the global
LOG.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in e180fa4. Restored the original logic that creates Heartbeat messages and changed to use getLog().onErrorEvent() for session-specific logging.