Details
-
New Feature
-
Resolution: Works as Designed
-
Major - P3
-
None
-
None
-
None
Description
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.
Attachments
Issue Links
- is caused by
-
GODRIVER-312 Ensure WriteErrors are returned to the user
-
- Closed
-