我刚刚体验到我的应用在每个页面加载或几乎每个页面加载时都有错误。重启清除了所有问题。这就是我认为发生的事情。
第一个错误是“IOError:无法重新打开:null”
"org/jruby/RubyIO.java" line 501 in reopen
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 52 in silence_stream
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 109 in quietly
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 50 in silence_stream
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 108 in quietly
"/app/vendor/bundle/jruby/1.9/gems/activerecord-session_store-0.1.0/lib/action_dispatch/session/active_record_store.rb" line 64 in get_session
"/app/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" line 266 in load_session
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 51 in stale_session_check!
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 168 in load!
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 160 in load_for_read!
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 86 in []
"/app/vendor/bundle/jruby/1.9/gems/warden-1.2.3/lib/warden/session_serializer.rb" line 30 in fetch
"/app/vendor/bundle/jruby/1.9/gems/warden-1.2.3/lib/warden/proxy.rb" line 212 in user
...
只有其中一个。然后,在每个页面请求上,我得到“Errno :: EBADF:Bad file descriptor”
"org/jruby/RubyIO.java" line 2097 in close
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 53 in silence_stream
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 109 in quietly
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 50 in silence_stream
"/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 108 in quietly
"/app/vendor/bundle/jruby/1.9/gems/activerecord-session_store-0.1.0/lib/action_dispatch/session/active_record_store.rb" line 64 in get_session
"/app/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" line 266 in load_session
"/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session
...
导致最初问题的原因是什么?
答案 0 :(得分:1)
Rails.logger.silence
和相关的不是100%线程安全https://gist.github.com/kares/9374772我已经处理过类似的问题(在JRuby on Rails上),自2.3以来肯定有尝试解决这个问题,但不知怎的,同样的沉默逻辑不断回归。
我猜,整个silence_stream(STDOUT) {}
代码(你的跟踪显示的代码)可能会以类似的“不可预测”状态结束。我会尝试修补 kernel / reporting.rb ,以便流消音器什么都不做(我也更新了要点)。