[SERVER-15292] Failed update reports erroneous WriteResult Created: 17/Sep/14  Updated: 04/Oct/23

Status: Backlog
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.4, 2.7.6
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Eric Daniels (Inactive) Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-13318 Update stats are incorrect after an e... Closed
is duplicated by SERVER-25716 multi-update in the presence of an er... Closed
Related
related to SERVER-45943 When write operation times out return... Closed
is related to SERVER-22252 Diagnostic log messages missing debug... Backlog
Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

1. Insert test data

db.test.insert({n: 1})
db.test.insert({n: 2, age: 1})
db.test.insert({n: 3})

2. Update data with multi

db.test.update({}, {$push: {age: 5}}, {multi: true})

Result:

WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 16837,
		"errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}"
	}
})

Expected?:

WriteResult({
	"nMatched" : 3,
	"nUpserted" : 0,
	"nModified" : 1,
	"writeError" : {
		"code" : 16837,
		"errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}"
	}
})

Participants:

 Description   

See reproduction. The erroneous fields are nMatched and nModified.

On a related note. The documentation on a collection update doesn't specify what happens when an update with multi fails on a specific document when more than one was matched.



 Comments   
Comment by Asya Kamsky [ 04/Jan/19 ]

Still the case in 4.1.4

Comment by David Storch [ 10/May/16 ]

The issue is that the UpdateStage uasserts when the UpdateDriver cannot apply the update modifiers. The resulting exception prevents us from calling UpdateStage::makeUpdateResult(), which is responsible for returning metrics like nMatched and nModified. This is similar to SERVER-22252, which describes another manifestation of missing debug info on query failure.

Generated at Thu Feb 08 03:37:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.