sdsykes / slim_scrooge

SlimScrooge heavily optimises your database interactions
313 stars 25 forks source link

(NoMethodError) "undefined method `each' for nil:NilClass" (rails-3.0.0 / ruby-1.9.2-p0) #12

Closed knoopx closed 13 years ago

knoopx commented 13 years ago

This is using rails-3.0.0 and ruby-1.9.2-p0. The exception is thrown randomly so I guess it happens at the 2nd or 3rd request.

/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/mysql2-0.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:628:in `select'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `block in select_all'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `cache_sql'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `select_all'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/slim_scrooge-1.0.10/lib/slim_scrooge/slim_scrooge.rb:19:in `find_by_sql_with_slim_scrooge'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/relation.rb:64:in `to_a'
/usr/local/rvm/gems/ruby-1.9.2-p0/ruby/1.9.1/gems/activerecord-3.0.0/lib/active_record/relation/finder_methods.rb:143:in `all'
sdsykes commented 13 years ago

It seems that the C library part of mysql2 is returning nil for whatever request is being sent to it. From reading the code I see that in certain circumstances this could happen, but I don't think you should be triggering it, and I can't see what from slim scrooge would trigger it unless the SQL query was invalid in some way.

I am still trying to reproduce this (no luck yet) but in the mean time, are you able to see the sql query that is last made before the crash from your log file?

sdsykes commented 13 years ago

Closed due to inactivity, can't reproduce