[Client] Fixed freezing of Subscription with sequential publishing#3565
Open
AnatolyKochnev wants to merge 1 commit intoOPCFoundation:masterfrom
Open
[Client] Fixed freezing of Subscription with sequential publishing#3565AnatolyKochnev wants to merge 1 commit intoOPCFoundation:masterfrom
AnatolyKochnev wants to merge 1 commit intoOPCFoundation:masterfrom
Conversation
- Fixed freezing of Subscription (messages were not moving from Subscription.m_incomingMessages to Subscription.m_messageCache). Was happening when sequentialPublishing is active and first received publish response had SequenceNumber greater when 1. - Constant Subscription.kRepublishMessageTimeout was made public (Subscription.REPUBLISH_MESSAGE_TIMEOUT) so it can be used in tests. - Added unit tests to cover fixed problem. - Added unit test to cover invalid handling of reordered message queue for sequential publishing (UnorderedMessagesWouldBeLostForSequentialPublishingAsync). For now, test was made [Explicit].
marcschier
reviewed
Feb 18, 2026
| /// <summary> | ||
| /// Duration to wait before republishing missed notification | ||
| /// </summary> | ||
| public const int REPUBLISH_MESSAGE_TIMEOUT = 2500; |
Collaborator
There was a problem hiding this comment.
Please leave the name as before to comply with naming conventions.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
The client subscription fails to move messages from
Subscription.m_incomingMessagestoSubscription.m_messageCache, which leads to a complete freeze of the subscription publishing state.Conditions Required to Reproduce
The issue occurs only when both of the following are met:
Subscription.SequentialPublishing = trueSubscription.SaveMessageInCachereceives the first message with aSequenceNumbergreater than1(availableSequenceNumbersis not relevant in this scenario)Root Cause
When sequential publishing is enabled, the subscription cannot process incoming messages if there is a gap in sequence numbers.
Subscription.SaveMessageInCachealready contains logic to handle gaps between messages. However, it does not handle the specific case where the first received message itself introduces the gap (i.e., when the sequence does not start from1).As a result:
Proposed changes
Subscription.SaveMessageInCacheto properly fill the gap betweenSubscription.m_lastSequenceNumberProcessedandIncomingMessage.SequenceNumberSubscriptionUnitTeststo validate scenarios involving unordered messages passed toSubscription.SaveMessageInCache.Notes
SequenceNumbercan be sent (see testUnorderedMessagesWouldBeLostForSequentialPublishingAsync).In this case, the subscription treats such a message as the latest received message.
This appears to be another bug. For now, the corresponding test is marked as [Explicit] for further investigation.
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that apply. You can also fill these out after creating the PR.Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.