moped icon indicating copy to clipboard operation
moped copied to clipboard

"key not found" error pops up sometimes after first query when Rails 4 server starts

Open markslemko opened this issue 10 years ago • 9 comments

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

markslemko avatar Aug 06 '14 23:08 markslemko

I'm seeing this a lot, especially in RailsAdmin controllers. Can provide traces from New Relic if needed.

jimsynz avatar Sep 09 '14 02:09 jimsynz

super weird.. which version of mongoid are you guys using ?

arthurnn avatar Sep 29 '14 14:09 arthurnn

from gemfile: gem 'mongoid', "~> 4.0.0" from gemfile.lock: mongoid (4.0.0) moped (2.0.0)

markslemko avatar Sep 30 '14 01:09 markslemko

Exactly the same here.

jimsynz avatar Sep 30 '14 01:09 jimsynz

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

arthurnn avatar Oct 21 '14 01:10 arthurnn

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)

chenkirk avatar Nov 11 '14 00:11 chenkirk

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'", 

asiazhang avatar Mar 28 '15 06:03 asiazhang

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'

jeremyhaile avatar Apr 06 '15 19:04 jeremyhaile

Can someone write an isolated app or test file, so I can simulate this error locally? thanks

arthurnn avatar Apr 07 '15 14:04 arthurnn