Highlighting bulk operations in MongoDB

In 2.6, a new kind of operation appeared that caused massive operations . It reminds me of transactions - the user can specify a set of records and subsequently execute them as described below

var bulk = db.users.initializeOrderedBulkOp(); bulk.insert( { user: "abc123", status: "A", points: 0 } ); bulk.insert( { user: "ijk123", status: "A", points: 0 } ); bulk.insert( { user: "mop123", status: "P", points: 0 } ); bulk.find( { status: "D" } ).remove(); bulk.find( { status: "P" } ).update( { $set: { comment: "Pending" } } ); bulk.execute(); 

Is bulk operation atomic? Is a potential consumer reading non-repeating or phantom?

+7
mongodb
source share
1 answer

From mongo documents: Operations on a single document are always atomic databases of MongoDB, however operations related to several documents, often referred to as "transactions with multiple documents", are not atomic.

Ordered and unordered operations

Mass write operations can be either ordered or disordered. With an ordered list of operations, MongoDB performs operations one at a time. If an error occurs while processing one of the write operations, MongoDB will return without processing any remaining write operations in the list .

http://docs.mongodb.org/manual/core/bulk-write-operations/

Conclusion: no transactions in bulk operations

+12
source share

All Articles