[DOCS-14287] Update command documentation should describe expected behavior when a multi-update fails Created: 11/Mar/21  Updated: 30/Oct/23  Resolved: 05/Aug/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Mihai Andrei Assignee: Lauren Tran
Resolution: Done Votes: 0
Labels: quick-fix
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 26 weeks, 6 days ago
Epic Link: DOCSP-11702
Story Points: 3

 Description   

Description

Page: https://docs.mongodb.com/manual/reference/command/update/index.html

Consider the following sequence of commands which results in a document validation failure:

> db.coll.insertMany([{a: 1, b:1}, {a: 2, b:2}, {a: 3, b:3}, {a:1, b:4}])
{
       "acknowledged" : true,
       "insertedIds" : [
               ObjectId("60429200cb07b1d94070d658"),
               ObjectId("60429200cb07b1d94070d659"),
               ObjectId("60429200cb07b1d94070d65a")
       ]
}
 
> db.coll.createIndex({b: 1})
{
       "createdCollectionAutomatically" : false,
       "numIndexesBefore" : 1,
       "numIndexesAfter" : 2,
       "ok" : 1
}
 
> db.runCommand({collMod: "coll", validator: {a: {$ne: 200}}})
{ "ok" : 1 }
 
> db.coll.updateMany({}, {$mul: {a: 100}}, {hint: {b: 1}})
                                                                                                                                                                                                                                                                              
> db.coll.find()
{
 "_id": ObjectId("6047934b5921dc2713d2b1e8"),
 "a": 100,
 "b": 1
}
{
 "_id": ObjectId("6047934b5921dc2713d2b1e9"),
 "a": 2,
 "b": 2
}
{
 "_id": ObjectId("6047934b5921dc2713d2b1ea"),
 "a": 3,
 "b": 3
}
{
 "_id": ObjectId("6047934b5921dc2713d2b1eb"),
 "a": 1,
 "b": 4
}

Note that once a single document fails to update, no other documents are updated. While this is correct behavior, some users may find this surprising as they might expect that the command will continue updating documents after a failure. As such, we should update the documentation of the ‘update’ command to describe what happens in the case of a multi-update that fails.

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 04/Aug/22 ]

Author:

{'name': 'ltran-mdb', 'email': '107217639+ltran-mdb@users.noreply.github.com', 'username': 'ltran-mdb'}

Message: DOCS 14287 - multi update failure documentation (#1531) (#1577)

Comment by Githook User [ 04/Aug/22 ]

Author:

{'name': 'ltran-mdb', 'email': '107217639+ltran-mdb@users.noreply.github.com', 'username': 'ltran-mdb'}

Message: DOCS 14287 - multi update failure documentation (#1531) (#1579)

Comment by Githook User [ 04/Aug/22 ]

Author:

{'name': 'ltran-mdb', 'email': '107217639+ltran-mdb@users.noreply.github.com', 'username': 'ltran-mdb'}

Message: DOCS 14287 - multi update failure documentation (#1531) (#1578)

Comment by Githook User [ 04/Aug/22 ]

Author:

{'name': 'ltran-mdb', 'email': '107217639+ltran-mdb@users.noreply.github.com', 'username': 'ltran-mdb'}

Message: DOCS 14287 - multi update failure documentation (#1531)

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