-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: 5.0.1
-
Component/s: None
-
Environment:jruby 9.0.1.0, celluloid 0.16.0
When using Mongoid in heavily concurrent parts of my app, I often run into this issue. Calling document.set(field_name: 1) sometimes triggers this error:
NoMethodError: undefined method `reject' for nil:NilClass
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/clients/options.rb" line 54 in mongo_client
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/clients.rb" line 94 in mongo_client
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/clients.rb" line 90 in collection
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable.rb" line 212 in persist_atomic_operations
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable.rb" line 195 in persist_or_delay_atomic_operation
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable.rb" line 146 in prepare_atomic_operation
- File "/home/app/vendor/bundle/jruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable/settable.rb" line 23 in set
Calling document.with({}).set(field_name: 1) seems to fix the issue.