-
Notifications
You must be signed in to change notification settings - Fork 7
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
The library is not thread safe when using Tcp provider #8
Comments
This part makes me believe its ok:
because we never read from the pipe at all, we only send |
^ @barakakha I left you a reply but I didn't hear back. Closing due to inactivity. |
Sorry for the delay.. I tested it in scale (1000 metric/sec) and it’s not thread safe. We got a lot of scrambled packets in the receiving server. This is because you have multiple writers. Even the implementation with the queue has some issues that the background worker just stop working and not running again which make the queue overflow and consume all the memory |
Do you have a repo where we can repro this? I think I get what you are saying, 2 threads are trying to concurrently write to the same stream which is causing the bits to get scrambled. I never used the TCP implementation, we ran UDP, and eventually our own transport, its likely to be the more untested at scale client. |
would you mind if i will send Pull Request to fix it using Blocking Collection? |
@TerribleDev can i send a pull request? or maybe just send you the changes (only in the Tcp class)? |
@barakakha definitely send over the TCP class stuff. I'd be worried about using a blocking collection as the threads will essentially block each other. The buffer stuff was never really well thought out, it certainly could use a re-do. |
In the Tcp provider class, in method SendAsync you use Stream.WriteAsync of NetworkStream without any synchronisation. Only if you use the buffer option it is thread-safe
according to the NetworkStream doc
The text was updated successfully, but these errors were encountered: