Skip to content
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

[FIXED] JetStream flow control may stall in some conditions #837

Merged
merged 3 commits into from Oct 5, 2021

Conversation

kozlovic
Copy link
Member

@kozlovic kozlovic commented Oct 5, 2021

Keep track of the "sequence" of incoming messages that are then compared with the number of delivered message.
However, ChanSubscription were broken: the FC would always be responded to when received, because pMsgs (and pBytes) would always be 0 for these type of subscriptions.

We now check for flow control on all incoming messages for ChanSubscription (and evaluate the "delivered" count based on the incoming sequence minus length of the user's channel). We also have a long-lived go routine to cover situations where the evaluation during the incoming message did not result in the target to send the FC, but then the user consumes enough messages to bring the "delivered" at or past the target. Without this go routine, the client would stall and have to wait for an heartbeat with the "fc stalled" header in order to be unblocked.

Alternatively, we could fail creation of ChanSubscription subscriptions if flow control is in use...

Finally, this PR fixes some issues with the ordered consumer test:

  • We send a "EOF" empty message which should not be counted as the number of chunks used to reconstitute the asset
  • Some "message filters" that are removed as part of the execution of the filter's callback would not be put back for the following "sync" test (we test async then sync).

Signed-off-by: Ivan Kozlovic ivan@synadia.com

@coveralls
Copy link

coveralls commented Oct 5, 2021

Coverage Status

Coverage decreased (-0.4%) to 86.8% when pulling c564a49 on js_fix_fc into 4a0ad2a on main.

js.go Outdated Show resolved Hide resolved
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Several issues:
- We send a "EOF" empty message which should not be counted as
the number of chunks used to reconstitute the asset
- Some "message filters" that are removed as part of the execution
of the filter's callback would not be put back for the following
"sync" test (we test async then sync).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kozlovic kozlovic merged commit 6305227 into main Oct 5, 2021
@kozlovic kozlovic deleted the js_fix_fc branch October 5, 2021 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants