Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-731

On write concern error, bulk insert raises error but still inserts

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.10.0
    • Affects Version/s: None
    • Component/s: None

      This only seems to be a problem with old-style write operations (wire_version 0) and not with the new write commands.

      We connect to a standalone mongod and use an empty collection.

      bulk = collection.initialize_ordered_bulk_op
      bulk.insert({:a => 1})
      bulk.insert({:a => 2})
      bulk.execute({:w => 2})
      

      We expect this call to raise a BulkWriteError, and it does. However, if we examine the collection afterwards, it will contain the first document we tried to insert,

      { "a" : 1 }

      Running the same steps with an unordered bulk op:

      bulk = collection.initialize_unordered_bulk_op
      bulk.insert({:a => 1})
      bulk.insert({:a => 2})
      bulk.execute({:w => 2})
      

      results in both

      { "a" : 1 }

      and

      { "a" : 2 }

      being inserted into the collection.

            Assignee:
            gjmurakami Gary Murakami
            Reporter:
            samantha.ritter@mongodb.com Samantha Ritter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: