Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4196

Atomic operations sometimes fail in heavily concurrent environments

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 5.1.0
    • 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.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            fedenusy13 Federico Nusymowicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: