-
Type:
Bug
-
Resolution: Cannot Reproduce
-
Priority:
Major - P3
-
Affects Version/s: 1.2.0
-
Component/s: None
-
None
-
Environment:OS X 10.6.4, Intel Core i7
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I receive the following error intermittently
NoMethodError:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
- /app/cd29e0d6-4516-42e7-937d-c4e873b510ac/home/.bundle/gems/ruby/1.8/gems/bson-1.2.0/lib/../lib/bson/ordered_hash.rb:71:in `[]='
looking at https://github.com/mongodb/mongo-ruby-driver/blob/1.2.0/lib/bson/ordered_hash.rb#L71 it doesn't seem like it should be possible.
68 def []=(key, value)
69 @ordered_keys ||= []
70 unless has_key?(key)
71 @ordered_keys << key # error throw here
72 end
73 super(key, value)
74 end
from the code it seems the @ordered_keys should have just been initialized on line 69. It's possible another thread is interfering but I thought the ruby driver was supposed to be thread safe.
The error occurs intermittently when I'm running my test suite. It's important to note that between each test the database is cleaned using
::Mongoid.database.collections.select
{ |c| c.name !~ /^system/ }.each { |c| c.remove({},
{"$atomic" => true}) }
I'm under the impression that $atomic should block any access to each collection until they've been removed. Perhaps this is not the case and the next test is inserting documents before the remove operation is performed?