Skip to content
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

Fix threading issues with BufferedLogger. #3394

Merged
merged 1 commit into from Oct 21, 2011

Conversation

bdurand
Copy link
Contributor

@bdurand bdurand commented Oct 21, 2011

There are a couple of threading issues with ActiveSupport::BufferedLogger.

If a thread is spawned and logs messages but does not flush the log, the messages will never be written and will remain in the buffer forever.

threads = []
urls.each do |url
threads << Thread.new do

logger.info("fetching #{url}")
fetch(url)
logger.info("#{url} retrieved")
end end
threads.each{|t| t.join}

Silencing a logger for a block in one thread will silence it will silence it for all other threads as well. This means in a multi-threaded Rails application, log messages can be lost.

(Note: this pull request was originally opened in Lighthouse at https://rails.lighthouseapp.com/projects/8994/tickets/6671)

josevalim added a commit that referenced this pull request Oct 21, 2011
Fix threading issues with BufferedLogger.
@josevalim josevalim merged commit b838570 into rails:master Oct 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants