Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-347

Write errors are not handled for command responses

    • Type: Icon: New Feature New Feature
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • None

      An example insert command that results in a duplicate key write error:

      > db.runCommand({ insert: "temp-metrics-coll", documents: [{"_id" : "sampleId-1521573287000000000"}] })
      {
      	"n" : 0,
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 11000,
      			"errmsg" : "E11000 duplicate key error collection: temp-metrics-db.temp-metrics-coll index: _id_ dup key: { : \"sampleId-1521573287000000000\" }"
      		}
      	],
      	"ok" : 1
      }
      

      I'm not sure why the ok field is set to 1 here. I have noticed this before, and I think this has caused issues with mgo in the past, specifically with duplicate key errors.

      Maybe this is a mongod bug? But the driver is also not checking for the writeErrors field. The relevant file is mongo/private/conn/protocl.go.

            Assignee:
            Unassigned Unassigned
            Reporter:
            thomas.delacour@mongodb.com Thomas Delacour (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: