[SERVER-10771] If applyOps encounters an error, indicate which op caused the error Created: 15/Sep/13  Updated: 24/Feb/16  Resolved: 13/Nov/15

Status: Closed
Project: Core Server
Component/s: Replication, Usability
Affects Version/s: None
Fix Version/s: 3.2.0-rc3

Type: Improvement Priority: Major - P3
Reporter: Cailin Nelson Assignee: Judah Schvimer
Resolution: Done Votes: 0
Labels: brs
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-10772 Add option to applyOps to allow conti... Closed
Backwards Compatibility: Minor Change
Sprint: RPL 1 04/03/15, TIG C (11/20/15)
Participants:

 Description   

A healthy run of an applyOps command returns something like the following:

{ "applied" : 3, "results" : [ true, true, true ], "ok" : 1 }

However, if an error occurs, the output does not indicate which op caused the failure, and instead looks like this:

{
	"errmsg" : "exception: E11000 duplicate key error index: fruit.fruit.$name_1  dup key: { : \"banana\" }",
	"code" : 11000,
	"ok" : 0
}

For example:

backup_test:PRIMARY> use fruit
switched to db fruit
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
}

It would useful to know that it was the 2nd op that caused the error.



 Comments   
Comment by Githook User [ 13/Nov/15 ]

Author:

{u'username': u'judahschvimer', u'name': u'Judah Schvimer', u'email': u'judah@mongodb.com'}

Message: SERVER-10771 applyOps indicates which op caused an error
Branch: master
https://github.com/mongodb/mongo/commit/26ad22c370276bf64a7c01f410006702d1736b92

Generated at Thu Feb 08 03:24:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.