[SERVER-25716] multi-update in the presence of an error gives incorrect nModified / nMatched value Created: 20/Aug/16  Updated: 06/Dec/22  Resolved: 29/Aug/16

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 3.2.8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrew Ryder (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-15292 Failed update reports erroneous Write... Backlog
Related
is related to SERVER-1599 support ability to pass hint to update Closed
Assigned Teams:
Query
Operating System: ALL
Steps To Reproduce:

db.test.drop()
db.test.ensureIndex({num:1},{unique:true})
db.test.insert([{num:0},{num:2},{num:4},{num:6},{num:7},{num:10}])
db.test.update({},{$inc:{num:1}},{multi:true})

Gives:

WriteResult({
        "nMatched" : 0,
        "nUpserted" : 0,
        "nModified" : 0,
        "writeError" : {
                "code" : 11000,
                "errmsg" : "E11000 duplicate key error collection: mt.test index: num_1 dup key: { : 7.0 }"
        }
})

But...

> db.test.find({},{_id:0})
{ "num" : 1 }
{ "num" : 3 }
{ "num" : 5 }
{ "num" : 6 }
{ "num" : 7 }
{ "num" : 10 }

3 documents were modified. We would expect "nMatched" and "nModified" to be at least 3.

Participants:

 Description   

If a multi:true update is run such that it fails halfway the resulting nModified / nMatched fields appear to always be set to zero (and the appropriate error given) even if documents have been modified.



 Comments   
Comment by David Storch [ 29/Aug/16 ]

Closing as a duplicate of SERVER-15292.

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