Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord::Base#silence / BufferedLogger Threadsafety Issues

#3024

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.

Reported by Christian Seiler · August 9th, 2009 @ 04:09 PM

State: stale
Milestone: none
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • 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.

    October 6th, 2010 @ 06:47 AM

  2. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:54 PM

  3. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:53 AM

  4. bingbing