Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10772

Add option to applyOps to allow continuing on error

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Usability
    • Replication

      Continuing on from SERVER-10771, it would also be nice if applyOps could continue on error, while returning details about the errors it encountered.

      For example in ....

      backup_test:PRIMARY> db.fruit.ensureIndex({name:1},{unique:true})
      backup_test:PRIMARY> db.fruit.insert({name: 'cherry'})
      backup_test:PRIMARY> db.fruit.insert({name: 'banana'})
      backup_test:PRIMARY> db.fruit.insert({name: 'pear'})
      backup_test:PRIMARY> db.fruit.remove({name: 'banana'})
      backup_test:PRIMARY> db.fruit.insert({name: 'banana'})
      backup_test:PRIMARY> use local
      switched to db local
      backup_test:PRIMARY> var ops = []; db.oplog.rs.find().sort({$natural:-1}).limit(5).forEach( function(opDoc) {ops.push(opDoc)});
      backup_test:PRIMARY> db.runCommand({applyOps: ops})
      {
      	"errmsg" : "exception: E11000 duplicate key error index: fruit.fruit.$name_1  dup key: { : \"banana\" }",
      	"code" : 11000,
      	"ok" : 0
      }
      

      ... the server fails on the 2nd op. It would be nice to have the option to have it continue on and finish the batch, while returning an array of responses indicating whether or not each op succeeded, and error messages for any ops that failed.

            Assignee:
            backlog-server-repl [DO NOT USE] Backlog - Replication Team
            Reporter:
            cailin.nelson@mongodb.com Cailin Nelson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: