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

Add option to applyOps to allow continuing on error

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Usability
    • Replication

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-repl Backlog - Replication Team
            cailin.nelson@mongodb.com Cailin Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: