-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove autoload code, it's not thread safe #919
Conversation
Woops, pardon me this doesn't work yet, I still have to reorder the dependencies and run the suite. Just submitting the PR as a discussion point for now :) |
Alright, specs pass this way :) |
Hmm, this will likely break people's workflow. How do other projects deal with this? Can we make Grape thread-safe(r) instead or turn auto-load off in production? Either way it needs a CHANGELOG entry. |
Mr Tenderlove has a blog article about it here: http://tenderlovemaking.com/2012/06/18/removing-config-threadsafe.html In ActiveSupport is a module called Autoload, it has a helper method that allows you to call eager_load on modules. What Rails does is including that module and then when config.thread_safe! is set, call it amongst other things. The module is really tiny, you could opt for that as well, it would disrupt peoples workflows a bit less I suppose. |
Grape already requires ActiveSupport, so maybe base it on that? |
Definitely, I'll push -f a version that uses that when I get the time, in the mean time I've ran into a thread safety bug in activerecord as well, so enabling multithreading is fun times all around for us ;) |
AFAIK, |
It is yes, but only in the sense that Ruby won't load the same file twice in the same thread. Race conditions and deadlocks might still occur. In any case, we are still locked on 1.9 for at least a couple of months. If you wanna go for just 2+ support then that's ok as well, we'll just keep using this fork in the meanwhile. |
Thanks @dm1try. I definitely don't want to merge this "as is", I would however merge something that plays nice with ActiveSupport autoload options. Will leave this open. |
Conflicts: lib/grape.rb
PR #980 fixes this I believe |
Hi guys,
We've been running into problems with the autoloads in grape. When running grape in a multithreaded app server it would have multiple concurrent requires which can lead to all sorts of nasty conditions.
I couldn't discover a way to put in thread safe mode so I just removed all the autoloads.
Do you have any other concerns with running Grape in a multithreaded app server?