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

applyOps reports success even when a nested applyOps fails.

    • Fully Compatible
    • ALL
    • v3.6, v3.4, v3.2
    • Repl 2018-01-15, Repl 2018-01-29, Repl 2018-02-12

      An applyOps inside of another applyOps always succeeds even where there's an error applying an operation:

      var oplog = {op:"i", ns: "test.test", o: {_id: 1}}
      db.dropDatabase()
      var res = db.adminCommand({applyOps: [oplog]})
      print('Invalid applyOps:' + tojson(res))
      // Command fails:
      // Invalid applyOps:{
      //     "applied" : 1,
      //     "code" : 26,
      //     "errmsg" : "Failed to apply insert due to missing collection: { op: \"i\", ns: \"test.test\", o: { _id: 1.0 } }",
      //     "results" : [
      //         false
      //     ],
      //     "ok" : 0
      // }
      res = db.adminCommand({applyOps: [{op: "c", ns: "admin.$cmd", o: {applyOps: [oplog]}}]})
      print('Nested invalid applyOps:' + tojson(res))
      // Command succeeds:
      // Nested invalid applyOps:{
      //     "applied" : 1,
      //     "results" : [
      //         true
      //     ],
      //     "ok" : 1
      // }
      

            Assignee:
            matthew.russotto@mongodb.com Matthew Russotto
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: