[GODRIVER-347] Write errors are not handled for command responses Created: 05/Apr/18  Updated: 27/Oct/23  Resolved: 23/Apr/18

Status: Closed
Project: Go Driver
Component/s: Administrative Commands
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Thomas Delacour (Inactive) Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by GODRIVER-312 Ensure WriteErrors are returned to th... Closed

 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.



 Comments   
Comment by Githook User [ 27/Apr/18 ]

Author:

{'email': 'kris@mongodb.com', 'username': 'skriptble', 'name': 'Kris Brandow'}

Message: Ensure write operation error are returned

GODRIVER-312
GODRIVER-307
GODRIVER-347

Change-Id: Ib3321215285029b9602f27ca4a89d588ef643238
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/0dfcbabcc0f2b9032e3f1ce413996c900f52a06c

Comment by Jeffrey Yemin [ 23/Apr/18 ]

No problem. It's always been a source of confusion that write errors are still ok : 1

Comment by Thomas Delacour (Inactive) [ 23/Apr/18 ]

jeff.yemin oh huh. There's no specific use case, but during development I noticed that I wasn't getting any errors back when inserting multiple test documents with the same _id. Certainly not specifically an issue for us; thanks for the clarification on where this would be seen as exceptional!

Comment by Jeffrey Yemin [ 23/Apr/18 ]

No other drivers do this (writeErrors are only seen as exceptional in the write command helper methods, e.g. insertOne, insertMany). thomas.delacour what's the use case?

Comment by Thomas Delacour (Inactive) [ 05/Apr/18 ]

Ok cool, thanks!

Comment by Kristofer Brandow (Inactive) [ 05/Apr/18 ]

This is a known issue and return "ok": 1. We just aren't returning write errors or write concern errors yet. This will be handled once GODRIVER-312 is implemented.

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