This project is archived and is in readonly mode.

#3024 ✓stale
Christian Seiler

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:

  1. first thread sets level from e.g. 0 to 3
  2. second thread comes along sees 3 as original log level
  3. first thread finishes and sets the level to 0
  4. 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

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>

Pages