-
Notifications
You must be signed in to change notification settings - Fork 698
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
jetstream: ordered consumer: handle closed subscriptions gracefully #1666
Conversation
Closes #1656 |
32fb4da
to
f28e14a
Compare
In `orderedConsumer.reset()`, `retryWithBackoff()` is returned from with `false, nil` in case the subscription is closed. In this case, `var cons Consumer` is still `nil`, and the code crashes in the attempt to cast it to a `pullConsumer` later on. Fix this by catching the `nil` case explicitly. Signed-off-by: Daniel Mack <[email protected]>
f28e14a
to
1de5b00
Compare
This is a regression from 66b92a9 it appears. |
@piotrpio ping |
@zonque sorry for the delay. |
It's tricky to test because the issue is triggered by a race condition between the creation of a consumer and the teardown of a NATS server. Not sure how this could be tested, but this is very clearly a bug, as you can easily identify the code path that leads to a |
Hello @zonque, thanks for finding this and sorry it tool so long to review. Your solution solves the nil pointer, but I have a few suggestions on how it can be improved:
My suggestion would be to:
Again, sorry it took that long. Let me know if you'll be working on that or I should take it off your hands. |
Thanks for the feedback. As you have a better view on the bigger picture, I think it might in fact be easier if you roll your own version of the fix? |
@zonque, sure, I'll take care of this and make sure the fix is included in the next release. |
I created a PR with the fix: #1686 So I'll be closing this one - thanks for your contribution! |
In
orderedConsumer.reset()
,retryWithBackoff()
is returned from withfalse, nil
in case the subscription is closed. In this case,var cons Consumer
is stillnil
, and the code crashes in the attempt to cast it to apullConsumer
later on.Fix this by catching the
nil
case explicitly.Signed-off-by: Daniel Mack [email protected]