Stacktrace when running Scout's Resque Monitoring plugin.
dobrite opened this issue · 9 comments
This might not be a multi_json
issue, but I thought I'd drop it in here in case it is. Feel free to close if it isn't.
scout has a Resque monitoring plugin that uses multi_json
gem which fails with the following stack trace:
NameError: uninitialized constant Class::OptionsCache
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:43:in `cached_load_options'
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:21:in `load'
/usr/lib/ruby/vendor_ruby/multi_json.rb:120:in `load'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque.rb:44:in `decode'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque/worker.rb:35:in `decode'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque/worker.rb:82:in `block in working'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque/worker.rb:80:in `map'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque/worker.rb:80:in `working'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque.rb:468:in `working'
/var/lib/gems/1.9.1/gems/resque-1.26.0/lib/resque.rb:489:in `info'
Resque Monitoring:21:in `build_report'
It looks like scout's agent is using Ruby 1.9.1
and multi_json
1.12.1
.
Any input is appreciated,
Dave
That's weird. require "multi_json/options_cache"
is one of the first things we do when MultiJson is loaded: https://github.com/intridea/multi_json/blob/v1.12.1/lib/multi_json.rb#L5
Could you fork MultiJson, bundle from github and see if putting require "multi_json/options_cache
" at the top of lib/multi_json/adapter.rb
or changing OptionsCache
to ::MultiJson::OptionsCache
in the same file fixes it?
Thanks for the quick response! I tried out the 2 changes. Unfortunately the scout runtime is opaque, but I found a way to debug it. Also unfortunately, neither of the options seemed to help, though option 1 seems to have gotten us a bit further.
Option 1 gave the following stack-trace:
NoMethodError: undefined method `key?' for nil:NilClass
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/options_cache.rb:12:in `fetch'
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:44:in `cached_load_options'
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:22:in `load'
Option 2 gave the following stack-trace:
NameError: uninitialized constant MultiJson::OptionsCache
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:43:in `cached_load_options'
/var/lib/gems/1.9.1/gems/multi_json-1.12.1/lib/multi_json/adapter.rb:21:in `load'
Ok, let's take another approach.
If you don't have MultiJson in your Gemfile, could you please add it explicitly and see if it fixes it? If it doesn't, try creating an initializer with require "multi_json"
in it and make sure it runs before the code in question.
I'm not convinced that this is an issue with multi_json
, but instead an issue with the scout plugin runtime. I filed an issue with them. I appreciate the time you spent replying and the quickness with which you do so. 😍
The above referenced issue is: scoutapp/scout-client#31
FWIW I had the exact same issue and I was able to get it to work by downgrading multi_json
to 1.11.2
(it was at 1.12.2
).
I am not sure what that indicates, but that was a fix for me.
FWIW I had the exact same issue and I was able to get it to work by downgrading multi_json to 1.11.2 (it was at 1.12.2).
THis work for me too
Anybody has a way to replicate the issue?
Oh jeez, the gem is doing something batshit insane there: https://github.com/scoutserver/scout-client/blob/v5.9.7.1/lib/scout/server.rb#L2-L8
Vendoring an older version of the gem and requiring it completely overwriting the existing one.
This is prone to all sorts of race conditions and crazy bugs, expecially given the lazy load nature of multi json, exactly the stuff you guys are seeing here.
This is not a MultiJson issue, this is 100% scout-client's problem.