-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add cancellation token during subscribe #206
Conversation
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Codecov ReportBase: 92.17% // Head: 91.98% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
- Coverage 92.17% 91.98% -0.20%
==========================================
Files 92 92
Lines 7966 7985 +19
Branches 640 641 +1
==========================================
+ Hits 7343 7345 +2
- Misses 492 507 +15
- Partials 131 133 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Hi! Thank your for the quick response and patch @Gsantomaggio We've been testing it during the day with various workloads and it's definitely alot better! At first we could still se about 0.5% of all closed connections get deadlocked with an error: ... but after tweaking our consumer messagehandlers that contained TaskCompletionSources with The reason why I'm mentioning the TaskCompletionSource tweak in our application code is that even if it works well now, and we're super grateful for this being fixed, the code still seems to be able to deadlock under certain conditions but I might be wrong... The Wait() in: rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/RawConsumer.cs Lines 160 to 162 in 9d34170
feels like some sort of a flaw (as mentioned before in #106 (comment) ) but on the other hand, I've no better suggestion at the very moment if Thanks again! |
@jonnepmyra let me clarify some points:
Have questions:
Thank you for trying the PR. :) p.s. If you want, you can find me at https://rabbitmq-slack.herokuapp.com/ |
Hi! Thanks for taking time to explain.
Yes, and I have not been able to reproduce it.
The Memoryleak seems to be fixed now, no connections left unclosed after tweaking application specific consumer code!
Yes, it seems fine Cheers! |
Great! We will merge it soon! |
Let's wait for some feedback from @ricardSiliuk @ricsiLT then, we can merge and release. |
I did some memory/threads test with millions of messages: Task.Run(() =>
{
while (true)
{
ThreadPool.GetMaxThreads(out var max, out _);
ThreadPool.GetAvailableThreads(out var available, out _);
var running = max - available;
Console.WriteLine(
$"{DateTime.Now:HH:mm:ss.fff} - Threads: {System.Diagnostics.Process.GetCurrentProcess().Threads.Count} " +
$"- {running}");
Thread.Sleep(1000);
}
});
....
MessageHandler = async (consumer, ctx, message) =>
{
if (++consumed % 10_000 == 0)
{
var timeMilliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
Console.WriteLine(
$"Client Consumed {consumed} messages in {timeMilliseconds - startTimestamp} ms stream: {Stream}");
}
await Task.Delay(1);
} Threads are stable:
Memory is stable: |
Fixes #205
In this way, the thread is not locked, and the:
is in wait(...), so there is not the thread pool exhaustion.
@ricardSiliuk @ricsiLT it should not change anything. Please feel free to add any comments.
@jonnepmyra do you have a chance to test it?
Signed-off-by: Gabriele Santomaggio G.santomaggio@gmail.com