[SERVER-75946] Make fixes to update response in bulkWrite Created: 11/Apr/23  Updated: 29/Oct/23  Resolved: 27/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Task Priority: Major - P3
Reporter: Sean Zimmerman Assignee: Frederic Vitzikam
Resolution: Fixed Votes: 0
Labels: milestone-1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Replication
Backwards Compatibility: Fully Compatible
Sprint: Repl 2023-05-01
Participants:

 Description   

There are multiple small changes that need to be made to the update response to make it more correct.

 

  1. Upserted response field in bulkWrite currently uses write_ops::Upserted like Update does. We should use IdlAnyTypeOwned like findAndModify does since we do not need to capture the index field.
  2. We currently only set nModified for an update response, we should set the n field also
  3. When an update fails, we should still set nModified for it in the response.

 

As part of this ticket it would also be nice to do some further cleanup by replacing the callback functions with passing around the BulkWriteReplies object and calling the functions directly

 

This will involve updating all relevant tests



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

Author:

{'name': 'Frederic Vitzikam', 'email': 'frederic.vitzikam@mongodb.com', 'username': 'fredvitz'}

Message: SERVER-75946 Make fixes to update response in bulkWrite
Branch: master
https://github.com/mongodb/mongo/commit/63e236b10600fe8df3eabe4758a3c012fb9fd652

Comment by Kaitlin Mahar [ 11/Apr/23 ]

For point 2 and 3, here's an example bulkWrite response when an update fails with an immutable field error and also a write concern error:

{
	"cursor" : {
		"id" : NumberLong(0),
		"firstBatch" : [
			{
				"ok" : 0,
				"idx" : 0,
				"code" : 66,
				"errmsg" : "Plan executor error during findAndModify :: caused by :: Performing an update on the path '_id' would modify the immutable field '_id'"
			}
		]
	},
	"writeConcernError" : {... },
	"ok" : 1,
}

vs. what the equivalent update command response contains

{
	"n" : 0,
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 66,
			"errmsg" : "Performing an update on the path '_id' would modify the immutable field '_id'"
		}
	],
	"nModified" : 0,
	"writeConcernError" : { ... },
	"ok" : 1,
        ...
}

 

Generated at Thu Feb 08 06:31:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.