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

Unsubscribe handling in async #1047

Merged
merged 2 commits into from Apr 5, 2022

Conversation

bjosv
Copy link
Contributor

@bjosv bjosv commented Feb 3, 2022

Redis responds to an unsubscribe with one or many replies, depending on the current subscribe state.
When channel/pattern names are provided in the unsubscribe command each given name will trigger a reply
even if duplicated or not subscribed to.

To know when we can switch the internal subscribe state we need to make sure all pending replies have been
processed before doing the switch. This is done by bookkeeping pending additional unsubscribe replies.

Fixes #1039

Redis responds to an unsubscribe with one or many replies, depending
on the current subscribe state. When channels/patterns names are
provided in a command each given name will trigger a reply even if
duplicated or not subscribed to.
To know when we can return from the subscribed state we need to do
bookkeeping on pending additional unsubscribe replies, and make sure
we receive them all before switching state.
@bjosv
Copy link
Contributor Author

bjosv commented Feb 3, 2022

The alternative solution would be to only send unsubscribe to channels/patterns that is subscribed to, i.e. change the command content, which is a bit more intrusive. We still need to bookkeep which channels/patterns that we have sent an unsubscribe to.

@michael-grunder michael-grunder merged commit d7683f3 into redis:master Apr 5, 2022
@michael-grunder
Copy link
Collaborator

Nice improvement, thanks!

@bjosv bjosv deleted the unsubscribe-handling branch August 4, 2022 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants