-
Notifications
You must be signed in to change notification settings - Fork 16
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
Critical: thread safety issues while using @instance vars (<=v3.0.2) #39
Comments
Hi Fernando @fernandomm first of all: thanks for using this component and giving feedback! You report something very mystic - never occurred until today. If I check the session initialization at: it is plain usage of ruby I am not sure if this is the server part or maybe an issue from continuously sending via Mail component or maybe also by Could you please try:
Looking forward to your feedback. After all it would be great when we get a test for this case. |
In addition you may also disable the pipelining once for a test run
|
Thank you for the quick reply and also for the amazing project. I was debugging the issue locally and found out that it might be caused by the I replaced it with a local variable and have been running the same test for 5+ minutes. It looks like it fixed the problem. I'm not sure why it's defined as an instance variable since it looks like it's only used inside that method. But I've also run the project's tests and it looks like i didn't break anything. I will review your suggestions to check if they might fix the problem without my changes. Otherwise, I could submit a PR with the fix that I mentioned. |
Hey Fernando @fernandomm what a CATCH ...
Same here midi-smtp-server/lib/midi-smtp-server.rb Line 1277 in a93dfb4
and here midi-smtp-server/lib/midi-smtp-server.rb Line 1242 in a93dfb4
and here midi-smtp-server/lib/midi-smtp-server.rb Line 1277 in a93dfb4
should be only a local var for Fernando, I will create an update tommorrow for a new release to fix this. I would like to add you to the Contributor list. https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/master/CONTRIBUTORS.md If you send me a PR just added yourself - I can merge that too! For now - THANKS A LOT for that fix |
@gencer - not sure if you already noticed this issue - guess its an important update for you! |
This will also need a fix for the v2.3.2 release and
|
No. Did not noticed this before. Perhaps due to some custom usages but this is serious (looking to codes and testing here since I got your notification). Thank you @TomFreudenberg for pinging me! |
@TomFreudenberg I'm glad I could help. I had to create a quick patch since this was affecting a production service. It's available in the following branch https://github.com/fernandomm/midi-smtp-server/tree/thread-safety-fix Should I submit it as a PR? I'm just not sure about how you would like to test this. In my experience it will usually happen when there is some I/O ( Eg.: saving a file ) and multiple connections. I'm able to reproduce it with this test but it makes the test suite slow. |
Hey Fernando @fernandomm cool that it already works on your production environment. I will check tomorrow if there are any special cases for the I cherry pick your commit from the above branch. Please append in there also your github id to the CONTRIBUTORS list. For the test I also have a look how we can manage the long runner tests but at least it should run. |
Ok, I've added myself in a separate commit to the same branch: fernandomm@7e2c17f. Thanks! |
Hey guys @gencer @fernandomm this issue is fixed ! Fernando, again thanks a lot for working on this. I have applied a new test based on yours at test/stress if you may have a look. With some random load during the auth processes I could easily manage to get the ctx overwritten in a false manner. If you both like and willing, I would be happy if you could run the tests once with the old code (v3.0.2) and post here that you also get a fail in that. I will post a new Gem for 3.0.3 as well as 2.3.3 tonight. Have a nice weekend |
All published and online |
Hey guys @gencer @fernandomm does it work on your side? Cheers, |
Hey @TomFreudenberg I'll test this ASAP and will get back to you. |
I've been running it in a staging environment. It works fine so far. Thanks again for the quick fix. |
In case nothing additional popped up :-) I guess it's done Cheers |
I still did not tested yet, I'll test on this weekend. Will write if anything goes wrong. |
Describe the bug
It looks like there are is a thread safety issue with the server. If there are concurrent connections, ctx might start mixing message info between connections.
To Reproduce
Steps to reproduce the behavior:
And when you check the server log, you will see this:
As you can see,
ctx[:server][:authorization_id]
got a value from another thread. I've also experienced issues withctx[:envelope][:from]
andctx[:envelope][:to]
values.Expected behavior
ctx values should be consistent when there are multiple connections.
System (please complete the following information):
The text was updated successfully, but these errors were encountered: