[SERVER-29263] Shell bulk api hides write concern errors when there is a write error and the bulk write is 'ordered' Created: 17/May/17  Updated: 19/Jun/23  Resolved: 19/Jun/23

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Do Votes: 0
Labels: move-stm, sdp-backlog-purge
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-28993 Duplicate key error returned after wr... Closed
Assigned Teams:
Server Development Platform
Operating System: ALL
Participants:

 Description   

It's possible for a write to fail both with a write error and a write concern error - for example if there is a duplicate key violation during an insert, we will still need to wait for write concern to ensure that the state that triggered the dup key error is visible across the majority of nodes. The shell bulk api, however, swallows write concern errors when doing an ordered bulk write if it encounters a write error. Unordered bulk writes correctly report both the write concern error and the write error.

replset:PRIMARY> db.test1.bulkWrite([{insertOne:{document:{_id:1}}}],{ordered:true,writeConcern:{w:2,wtimeout:1000}})
2017-04-27T16:38:39.568-0400 E QUERY    [thread1] BulkWriteError: write error at item 0 in bulk operation :
BulkWriteError({
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 11000,
			"errmsg" : "E11000 duplicate key error collection: test.test1 index: _id_ dup key: { : 1.0 }",
			"op" : {
				"_id" : 1
			}
		}
	],
	"writeConcernErrors" : [ ],
	"nInserted" : 0,
	"nUpserted" : 0,
	"nMatched" : 0,
	"nModified" : 0,
	"nRemoved" : 0,
	"upserted" : [ ]
})
 
replset:PRIMARY> db.test1.bulkWrite([{insertOne:{document:{_id:1}}}],{ordered:false,writeConcern:{w:2,wtimeout:1000}})
2017-04-27T16:38:17.558-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.test1 index: _id_ dup key: { : 1.0 }",
			"op" : {
				"_id" : 1
			}
		}
	],
	"writeConcernErrors" : [
		{
			"code" : 64,
			"codeName" : "WriteConcernFailed",
			"errInfo" : {
				"wtimeout" : true
			},
			"errmsg" : "waiting for replication timed out"
		}
	],
	"nInserted" : 0,
	"nUpserted" : 0,
	"nMatched" : 0,
	"nModified" : 0,
	"nRemoved" : 0,
	"upserted" : [ ]
})
BulkWriteError@src/mongo/shell/bulk_api.js:372:48
BulkWriteResult/this.toError@src/mongo/shell/bulk_api.js:336:24
Bulk/this.execute@src/mongo/shell/bulk_api.js:1173:1
DBCollection.prototype.bulkWrite@src/mongo/shell/crud_api.js:191:20
@(shell):1:1



 Comments   
Comment by Alex Neben [ 19/Jun/23 ]

This has been identified as work that the SDP team won't do in the near term. Please reopen with a comment if you feel this work should be reprioritized and explain why.

Comment by Steven Vannelli [ 10/May/22 ]

Moving this ticket to the Backlog and removing the "Backlog" fixVersion as per our latest policy for using fixVersions.

Generated at Thu Feb 08 04:20:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.