OPTIONS

$isolated

$isolated

The $isolated isolation operator isolates a write operation that affects multiple documents so that once the first document is changed the operation will not yield, to allow reads or writes, until all documents are written. This significantly affects the concurrency of the system as it holds the write lock much longer than normal.

Note

The $isolated isolation operator does not provide “all-or-nothing” atomicity for write operations.

Consider the following example:

db.foo.update( { field1 : 1 , $isolated : 1 }, { $inc : { field2 : 1 } } , { multi: true } )

Without the $isolated operator, multi-updates will allow other operations to interleave with these updates. By specifying $isolated you can guarantee isolation for the entire multi-update so no other clients sees the changes until the operation is finished (or errors – see the note above).

Warning

$isolated does not work with sharded clusters.

See also

See db.collection.update() for more information about the db.collection.update() method.

$atomic

Deprecated since version 2.2: The $isolated operator replaces $atomic.

ON THIS PAGE