Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Intermittent nil dereference from the 2.2.3 bind values support code #123

Closed
willbryant opened this Issue Jun 7, 2012 · 2 comments

Comments

Projects
None yet
2 participants

Not much to go on at the moment, but on something like one run out of a hundred of our cucumber suite, we get a strange nil dereference coming from a bit of code that hooks up Arel bind values to ActiveRecord inserts.

The code in question is in lib/arel/visitors/bind_visitor.rb whose introduction was the sole diff from 2.2.2 in 2.2.3, so I was hoping you could give me some more background on the change.

I'm not clear on how the visitor stuff is used but my interpretation of the below backtrace is that there is one fewer bind value being provided than the AST expects. Is that reasonable?

I can't figure out how this could be intermittent. The model class in question has no magic stuff. Could well be an ActiveRecord bug but given bind_visitor only just went in, I am hazarding a guess it's Arel.

(We are running an older version of Rails - from 3-1-stable - but master has no relevant changes to this code that I can see, 4bc2ae0 being the only vaguely related thing, so I believe it's not already fixed. And I can't see anything wrong in the higher-level ActiveRecord calls nor the aliased methods to do query caching, transaction isolation levels, etc.)

undefined method `reverse' for nil:NilClass
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:10:in `to_sql'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/bind_visitor.rb:17:in `call'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/bind_visitor.rb:17:in `visit_Arel_Nodes_BindParam'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `send'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `visit'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:119:in `visit_Arel_Nodes_Values'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:117:in `map'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:117:in `visit_Arel_Nodes_Values'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `send'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `visit'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:82:in `visit_Arel_Nodes_InsertStatement'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `send'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:19:in `visit'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/visitor.rb:5:in `accept'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:18:in `accept'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/to_sql.rb:16:in `accept'
/var/anonymized/vendor/bundle/ruby/1.8/gems/arel-2.2.3/lib/arel/visitors/bind_visitor.rb:11:in `accept'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `to_sql'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:91:in `insert'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/relation.rb:70:in `insert'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/persistence.rb:313:in `create'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/timestamp.rb:51:in `create'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/callbacks.rb:268:in `create'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:390:in `_run_create_callbacks'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:81:in `send'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/ac...tiverecord/lib/active_record/callbacks.rb:268:in `create'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/persistence.rb:294:in `create_or_update'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/callbacks.rb:264:in `create_or_update'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:399:in `_run_save_callbacks'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:81:in `send'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/callbacks.rb:264:in `create_or_update'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/persistence.rb:57:in `save!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/validations.rb:56:in `save!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:246:in `save!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
/var/anonymized/vendor/bundle/ruby/1.8/gems/transaction_isolation_level-0.1.0/lib/transaction_isolation_level/adapter_patches.rb:43:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction_without_isolation_level'
/var/anonymized/vendor/bundle/ruby/1.8/gems/transaction_isolation_level-0.1.0/lib/transaction_isolation_level/adapter_patches.rb:43:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:208:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:246:in `save!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/has_many_association.rb:14:in `insert_record'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:436:in `create_record'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:344:in `add_to_target'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:434:in `create_record'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:147:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/gems/transaction_isolation_level-0.1.0/lib/transaction_isolation_level/adapter_patches.rb:43:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction_without_isolation_level'
/var/anonymized/vendor/bundle/ruby/1.8/gems/transaction_isolation_level-0.1.0/lib/transaction_isolation_level/adapter_patches.rb:43:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/transactions.rb:208:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:146:in `transaction'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:433:in `create_record'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_association.rb:115:in `create!'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_proxy.rb:53:in `__send__'
/var/anonymized/vendor/bundle/ruby/1.8/bundler/gems/rails-a84c005e35d2/activerecord/lib/active_record/associations/collection_proxy.rb:53:in `create!'
/var/anonymized/features/step_definitions/signup_steps.rb:126

I banged my head against this for several hours...then I thought to turn the query_reviewer gem off. It worked.

Haven't seen this one for a while, so closing.

@willbryant willbryant closed this Jul 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment