-
Notifications
You must be signed in to change notification settings - Fork 230
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
Unsafe concurrent writes #196
Comments
Thanks for identifying this @thedevop! Apologies again for the delay. With 1. we potentially introduce lock contention, but with 2. we lose the ability to prioritise control messages (if memory serves, the spec indicates that certain messages should not be delayed based on the order of transmission of publish packets).
|
The use case I have is a bit different, currently it's mainly one way communication from client -> broker (will change in the future). Messages from broker to client are mostly control messages. The environment handles very large number of concurrent clients, but limited amount of message per client. The bottlenecks I see so far are (in order):
Logically, since each client only has 2 threads: read and write, the client also has buffered channel to handle publishing, there will not be any cross-client lock contentions. Then the only time lock contention occurs is between read/write thread, as intended. |
I opted for solution 1 as it was simpler - this should be fixed in v2.2.8 👍🏻 |
Resurfacing this issue.
Currently, both the client read/write Go routine may call cl.WritePacket:
https://github.com/mochi-co/mqtt/blob/7bd7bd5087c40f96015a61d01ce7ae4e6951c807/clients.go#L481
An example of when this can occur:
Possible solutions include:
https://github.com/mochi-co/mqtt/blob/7bd7bd5087c40f96015a61d01ce7ae4e6951c807/clients.go#L554
The text was updated successfully, but these errors were encountered: