-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
ActionController::Caching::Sweeper controller instance is not thread safe #643
Comments
Imported from Lighthouse. +1 |
Imported from Lighthouse. This often yields to the following errors when two requests overlap on the sweeper
Workaround: class ActionController::Caching::Sweeper
def controller
Thread.current[:"#{self}_controller"]
end
def controller=(c)
Thread.current[:"#{self}_controller"] = c
end
end |
Imported from Lighthouse. +1 Ran in to this (several times a second...) when trying to use Rails with config.threadsafe! |
Imported from Lighthouse. I'd take this as fix for 2-3-stable and possibly 3-0-stable. but for master we should probably do this right and have a sweeper instance per controller rather than a weird 'instance variable backed by a thread local'. There's a reason why we have a controller per request rather than request, session, etc all being in Thread.current. Care to take a stab at that larger refactoring? |
Imported from Lighthouse. Running into this issue regularly in production. +1 |
Attachments saved to Gist: http://gist.github.com/971647 |
With self referential associations, the scope for the the top level should not affect fetching of associations, for example when doing Person.male.find :all, :include => :friends we should load all of the friends for each male, not just the male friends.
This has not yet been solved Can the issue be reopened? |
I'm also still running into this on 2.3.14. Is this something that could still be accepted into 2-3-stable? |
Monkey patch for 2.3.14, for those who can't wait :-)
|
Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/3457
Created by blythe - 2009-11-04 21:11:46 UTC
Since Sweeper is a singleton(derived from
ActiveRecord::Observer
orActiveModel::Observer
edge) it seems that multiple threads could modify the single controller instance set and cleared in the around_filter.Would using
Thread.current
be preferable?The text was updated successfully, but these errors were encountered: