dwbutler/logstash-logger

Stack overflow in silenced_logging.rb after upgrading to 0.17.0

adamvduke opened this issue · 4 comments

I created a minimal sample app to replicate the issue. https://github.com/adamvduke/logstash-logger-test

Going back to 0.16.0 resolves the issue, but I haven't had time to dig in to exactly what the problem might be.

There is some custom logger configuration in development.rb which replicates what we are using in production.

~/src/logstash-logger-test (master=)$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/logstash-logger-0.19.0/lib/logstash-logger/silenced_logging.rb:44:in `thread_level': stack level too deep (SystemStackError)
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-session_store-1.0.0/lib/active_record/session_store/extension/logger_silencer.rb:31:in `level_with_threadsafety'
         ... 10067 levels...
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /Users/adamduke/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

I see what's going on. LogStashLogger's implementation of silenced logging is interfering with ActiveRecord::SessionStore's (from which it is derived).

Fix released in 0.19.1.

👍🏻 I'll try it out this coming week.

I deployed this morning and everything seems to be working. Cheers on the super fast turn around!