Error During Fail Safe Response Shifting Failed. Closed Stream
Translation patches Defect #8315 Unexplained breakage Added by Scot Wilcoxon over 5 years ago. Updated over 5 years ago. Status:ClosedStart date:2011-05-06Priority:HighDue date:Assignee:-% Done:0%Category:-Target version:- Resolution:Invalid Affected version: Description Is Redmine supposed to report its problems someplace? I inherited a Redmine server, and it recently quit working. The error doesn't hint at any configuration file or what might have broken. The files all seem to be lib files which are unlikely to have been altered during installation, much less something which broke without being touched. I found mention that "Shifting failed" might be related to log files, but I don't see any log configuration in environment.rb. I tried adding a log limit definition, but the error remains. Error during failsafe response: Shifting failed. closed stream[ pid=10657 thr=-609445668 file=utils.rb:176 time=2011-05-06 12:43:06.915 ]: *** Exception NoMethodError in application (undefined method `each' for nil:NilClass) (process 10657, thread #
Sign in Pricing Blog Support Search GitHub This repository Watch 8 Star 359 Fork 90 tra/spawnling Code Issues 5 Pull requests 0 Projects 0 Wiki Pulse Graphs New issue Problem with log rotation #10 Closed http://www.redmine.org/issues/8315 Simbul opened this Issue May 31, 2010 · 6 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 3 participants Simbul commented May 31, 2010 I've had some https://github.com/tra/spawnling/issues/10 very weird crashes while using spawn. I've tested high and low, and all I could find out is that it seems related to log rotation. A consistent behavior I experienced: when the log rotates, either the parent or the child process becomes unable to write on the new logfile (maybe because of a stale file handler?). Sometimes this seems connected to the crash, sometimes not. Anyway, this is the backtrace: Read error: # You might have expected an instance of Array. The error occurred while evaluating nil.each> /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:196:in initialize'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:14:innew' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:14:in call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:incall' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in process'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:inorig_process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:inorig_process_client' /Users/simbul/Sites/spawnlog/vendor/plugins/spawn/lib/patches.rb:61:in process_client'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:inrun' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in initialize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:innew' /System/Library/Frameworks/Ruby.fra
の Logger ってスレッドセーフ(&プロセスセーフ)なんだっけ?と疑問に思ったので調べてみました。特にマルチプロセス環境で Logger の shift_age オプションを使ってログローテーションさせようとした場合に大丈夫なのかな、と。なお、検証コードには楽するためにparallelgem を使用しましたが、特に問題なかろうかと思います。 ほとんど同じインターフェースでマルチスレッドとマルチプロセスを切り替えられるので便利です。マルチスレッドでログが混ざらないかマルチプロセスでログが混ざらないかマルチスレッドでのログローテーションは大丈夫かマルチプロセスでのログローテーションは大丈夫かまとめ1. マルチスレッドでログが混ざらないかコードrequire 'logger' require 'parallel' logger http://blog.livedoor.jp/sonots/archives/32645828.html = Logger.new("/tmp/test.log") Parallel.map(['a', 'b'], :in_threads => 2) do |letter| 300000.times do logger.info letter * 5000 end end ログの出力混ざりませんね$ egrep -e 'ab' -e 'ba' /tmp/test.log
[空]
$ head -4 /tmp/test.log
I, [2013-09-29T22:35:32.816742 #29827] INFO -- : aaaaaaaaaaaaaaaaaaa ... I, [2013-09-29T22:35:32.823871 #29827] INFO -- : bbbbbbbbbbbbbbbbbbb ... I, [2013-09-29T22:35:32.816742 #29827] INFO error during fail -- : aaaaaaaaaaaaaaaaaaa ... I, [2013-09-29T22:35:32.823871 #29827] INFO -- : bbbbbbbbbbbbbbbbbbb ... 考察ソースコードを見ても mutex を使って排他制御しているので問題なさそうですね。logger.rb#L559 def write(message) begin @mutex.synchronize do ... @dev.write(message) ... end 2. マルチプロセスでログが混ざらないかmutex で排他制御できるのはプロセス内のスレッド間までだよねー、ということでマルチプロセスな場合でも確認してみましょう。コードrequire 'logger' require 'parallel' logger = Logger.new("/tmp/test.log") Parallel.map(['a', 'b'], :in_processes => 2) do |letter| 300000.times do logger.info letter * 5000 end end ログの出力混ざりませんね$ egrep -e 'ab' -e 'ba' /tmp/test.log [空] $ head -4 /tmp/test.log I, [2013-09-29T22:35:32.816742 #29827] INFO -- : aaaaaaaaaaaaaaaaaaa ... I, [2013-09-29T22:35:32.823871 #29827]