MongoDB multi update consistency I have a collection similar to the below, of say 5,000,000 records. 

{ "_id" : ObjectId("56d18f95d2961d1ddcb7244f"), 
  "rec_id" : 0, 
  "status" : "open", 
  "updated by" : "A" 
}


User B is trying to mark all status to "closed", with below command:

db.prod.update({},{'$set': {'status':'closed', 'updated by':'B'}}, false, true)


Let's say user B is able to update closed status to 100,000 records and the connection is lost, or some problem occurs, and the remaining docs are not updated. So the data is inconsistent, is there any way in which we can fix this kind of problem?

I need to mark all status to closed or nothing to closed.
The documentation states


  When a single write operation modifies multiple documents, the modification of each document is atomic, but the operation as a whole is not atomic


Multi-row rollback is one of those things which are foregone in the NoSQL world, sadly.

That same link mentions the $isolated operator. This may be of some help, depending on the use case and topology.

Also documented is the so-called "two phase commit" pattern. This may require application changes, however, so may not be practical.

Five million rows isn't a silly-big number. Would it be possible to arrange an application outage until the writes succeed, with continuous retries? Maybe run the write application on the same hardware as Mongo so the network is no longer an issue.