-
Notifications
You must be signed in to change notification settings - Fork 169
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
Don't tokio::spawn
Subscriber::unsubscribe
#1061
Conversation
We only kill off the channels on reconnect tho (which doesn't send unsub because it's re-establishing the state) so this could lead to subscriptions hanging around longer than intended. |
One of the things we really care about in the NATS org are idle resources. Your reasoning is correct - if anything for a deleted subscription would come in, it would delete it and unsubscribe. However if nothing comes in - that subscription is still registered on the server and becomes a zombie. In global topologies containing millions of subscriptions and idle resources, such things can add up. I do realize there is a small possibility for it to happen and that the current approach is not perfect either, but I wanted to give you context why we're not merging it as of yet. |
Alternative approach could be to poll the closed future on the subscriptions themselves. |
I have a similar idea but it will have to wait for #1060 |
This will make sure we don't loose unsubscriptions. It'll be fun to fix the merge conflict with #1060 🙄 |
883fb5a
to
2433397
Compare
I'm trying to figure out why some benchmarks got worse. |
2433397
to
dbccc6d
Compare
dbccc6d
to
f58204c
Compare
f58204c
to
d4c209a
Compare
I redid the benchmarks and the regressions seem to have gone away
|
This changes
Subscriber
to usetry_send
instead ofsend
to send theUnsubscribe
command.Considering that the only advantage of
send
is that it waits until it finds an empty position in the channel before writing, whiletry_send
fails if the channel is full, it didn't make sense to usesend
as it required theFuture
to betokio::spawn
ed, sort of like using an unbounded queue to write into a bounded one.Considering that the
ConnectionHandler
already catches missed unsubscriptions, I think it's fair to rely more on it.nats.rs/async-nats/src/lib.rs
Lines 478 to 484 in eb4d492