- Reference >
- Operators >
- Update Operators >
- Isolation Update Operator >
- $isolated
$isolated¶
On this page
Definition¶
-
$isolated
¶ Prevents a write operation that affects multiple documents from yielding to other reads or writes once the first document is written. By using the
$isolated
option, you can ensure that no client sees the changes until the operation completes or errors out.This behavior can significantly affect the concurrency of the system as the operation holds the write lock much longer than normal for storage engines that take a write lock (e.g. MMAPv1), or for document-level locking storage engine that normally do not take a write lock (e.g. WiredTiger),
$isolated
operator will make WiredTiger single-threaded for the duration of the operation.
Behavior¶
The $isolated
isolation operator does not provide
“all-or-nothing” atomicity for write operations.
$isolated
does not work with sharded clusters.
Example¶
Consider the following example:
db.foo.update(
{ status : "A" , $isolated : 1 },
{ $inc : { count : 1 } },
{ multi: true }
)
Without the $isolated
operator, the multi
-update
operation will allow other operations to interleave with its update of
the matched documents.
See also
-
$atomic
¶ Deprecated since version 2.2: The
$isolated
operator replaces$atomic
.