This project is archived and is in readonly mode.
ActiveRecord::Base#silence / BufferedLogger Threadsafety Issues
Reported by Christian Seiler | August 9th, 2009 @ 04:09 PM
ActiveRecord::Base#silence temporarily sets the logger to a higher level which is a no-go in a multithreaded environment. In case of config.threadsafe! (and true concurrency with JRuby) this more or less immediately leads to a quiet logger:
- first thread sets level from e.g. 0 to 3
- second thread comes along sees 3 as original log level
- first thread finishes and sets the level to 0
- second thread finished and sets level to 3
=> log level is screwed up.
IMO Temporary log level changes should generally be disabled when config.threadsafe!
Workaround: monkey-patch the method
module ActiveRecord
class Base
def self.silence
yield
end
end end
Add then I think there is a system-level threadsafety issue, too: The level accessor methods of BufferedLogger are not protected from simultaneous changes.
Comments and changes to this ticket
-
Rohit Arondekar October 6th, 2010 @ 06:47 AM
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>