moped
moped copied to clipboard
"key not found" error pops up sometimes after first query when Rails 4 server starts
I'm not sure where or what this bug is coming from, but it happens pretty often. I'm wondering, has anyone seen this and know what is going on and how to fix it?
examples:
- A KeyError occurred in mycontroller#create:
- key not found: ">"
the line of code that triggers the strangeness is like this: User.find(params[:user_id]) or Game.find(params[:game_id']) where params[:user_id] = "5099e92f2008726e53000001"
Other examples:
- A KeyError occurred in mycontroller#create:
- key not found: ""
- A KeyError occurred in mycontroller#create:
- key not found: "w"
- A KeyError occurred in mycontroller#index:
- key not found: "P"
Any thoughts appreciated
I'm seeing this a lot, especially in RailsAdmin controllers. Can provide traces from New Relic if needed.
super weird.. which version of mongoid are you guys using ?
from gemfile: gem 'mongoid', "~> 4.0.0" from gemfile.lock: mongoid (4.0.0) moped (2.0.0)
Exactly the same here.
stacktrace would be helpful. Also if you could simulate this error in a script, that would help a lot debugging the issue. You can use https://github.com/mongoid/mongoid/blob/master/examples/mongoid_test.rb as a baseline
The stack trace for my error looks like this
https://gist.github.com/chenkirk/beaef6f86cae362a836a
device_service.rb:4
@device = Device.find_or_initialize_by(:device_id => device_id, :game_id => game_id)
same here.
error: key not found: "a"
backtrace:
"/root/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bson-2.3.0/lib/bson/registry.rb:43:in `fetch'",
"/root/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bson-2.3.0/lib/bson/registry.rb:43:in `get'",
"/root/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bson-2.3.0/lib/bson/hash.rb:79:in `from_bson'",
"/root/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/connection_pool-2.0.0/lib/connection_pool.rb:58:in `with'",
I'm getting this over and over on mongoid 4.0.2
2015-04-06T19:28:27Z 18126 TID-zp2uks WARN: key not found: "b"
2015-04-06T19:28:27Z 18126 TID-zp2uks WARN: /Users/jhaile/.rvm/gems/ruby-2.1.1/gems/bson-2.3.0/lib/bson/registry.rb:43:in
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/bson-2.3.0/lib/bson/registry.rb:43:in `get'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/bson-2.3.0/lib/bson/hash.rb:79:in `from_bson'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/bson-2.3.0/lib/bson/array.rb:99:in `from_bson'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/bson-2.3.0/lib/bson/hash.rb:79:in `from_bson'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:133:in `block (2 levels) in read'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:132:in `times'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:132:in `each'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:132:in `map'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:132:in `block in read'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:224:in `with_connection'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:114:in `read'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/protocol/query.rb:213:in `receive_replies'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:152:in `block in receive_replies'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:151:in `map'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/connection.rb:151:in `receive_replies'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/node.rb:591:in `block (2 levels) in flush'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/node.rb:182:in `block in ensure_connected'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/node.rb:115:in `block in connection'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/connection_pool-2.1.3/lib/connection_pool.rb:62:in `with'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/node.rb:114:in `connection'
/Users/jhaile/.rvm/gems/ruby-2.1.1/gems/moped-2.0.4/lib/moped/node.rb:178:in `ensure_connected'
Can someone write an isolated app or test file, so I can simulate this error locally? thanks