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

Possible session leak #121

Open
ctron opened this issue Dec 14, 2022 · 3 comments
Open

Possible session leak #121

ctron opened this issue Dec 14, 2022 · 3 comments

Comments

@ctron
Copy link
Contributor

ctron commented Dec 14, 2022

I have the feeling there is a session leak in the server code in case the server gets "too many" messages.

This is the scenario:

  • Use the subs.rs example

  • Instead of returning Ok() in the publish method, use:

    tokio::time::sleep(Duration::from_secs(1)).await;
    Err(MyServerError)
  • Implement Drop for MySession, print out something

Now when you send one message, it processes it, fails, closes the connection and prints out the message from drop.

If you send e.g. 20 messages at once, it processes all of the, closes the connection, but doesn't print out the message. This is pretty reproducible.

My assumption is, the session is still lingering somewhere.

@fafhrd91
Copy link
Member

I found cause of the problem, this is deadlock on protocol level. I don't think it is possible to fix this problem. I will try to mitigate it with keep-alive timer.

v3 server has in-flight limit, but default it is 16 message, if client sends 16 publishes server stops reading from socket, implementation of publish service in subs example sends publishes to client and expect ack before it ack's client's publish, but if server stops reading incoming data it cannot read ack from client so all inflight publishes stays in queue and never resolves.

@ctron
Copy link
Contributor Author

ctron commented Dec 15, 2022

Tricky. Wouldn't it work if (in this case) the socket would be closed, and so at least the session could be cleaned up? Sending either a "peer gone" event, or some dedicated "session overflow" event?

@fafhrd91
Copy link
Member

problem is that we pause read/write operations on socket, we cannot get disconnect event from it. i’ve been thinking about timeout if socket operations stop, i will try to build something next couple days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants