[GODRIVER-400] reorder conditionals to return write errors if a write concern error is also present. Created: 01/May/18  Updated: 28/Oct/23  Resolved: 31/Jan/19

Status: Closed
Project: Go Driver
Component/s: Error Handling
Affects Version/s: None
Fix Version/s: 0.3.0

Type: New Feature Priority: Major - P3
Reporter: Sam Kleinman (Inactive) Assignee: Isabella Siu (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In the event that a write operation returns both a write error and a write concern error, we should propagate both of these errors to users.



 Comments   
Comment by Githook User [ 31/Jan/19 ]

Author:

{'name': 'Isabella Siu', 'email': 'isabella.siu@10gen.com', 'username': 'iwysiu'}

Message: GODRIVER-400 return multiple errors for write operations

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

Comment by Jeffrey Yemin [ 01/May/18 ]

You can definitely get both:

MongoDB Enterprise repl0:PRIMARY> db.test.insert({_id: 1})
MongoDB Enterprise repl0:PRIMARY> db.test.insertMany([{_id : 1}, {_id: 2}], {ordered: false, writeConcern: {w : 2, wtimeout: 1}} )
2018-05-01T17:34:29.538-0400 E QUERY    [thread1] BulkWriteError: write error at item 0 and problem enforcing write concern in bulk operation :
BulkWriteError({
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 11000,
			"errmsg" : "E11000 duplicate key error collection: test.test index: _id_ dup key: { : 1.0 }",
			"op" : {
				"_id" : 1
			}
		}
	],
	"writeConcernErrors" : [
		{
			"code" : 64,
			"codeName" : "WriteConcernFailed",
			"errmsg" : "waiting for replication timed out",
			"errInfo" : {
				"wtimeout" : true
			}
		}
	],
	"nInserted" : 1,
	"nUpserted" : 0,
	"nMatched" : 0,
	"nModified" : 0,
	"nRemoved" : 0,
	"upserted" : [ ]
})

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