There is always a certain level of blocking, which, depending on your version of MongoDB, can be either collection, or an older database level, or even, possibly, a document level with the WiredTiger engine. $out , however, works on write, so individual documents are output from the pipeline, not all at a time, so each update is atomic to the document.
Even the mapReduce command has this parameter , where you can set "nonAtomic" as a condition under which the output mapReduce collection will exhibit the same behavior.
The only thing you need to know with $out is to remove all documents from the collection (not replacing existing indexes), since this step is performed using the "replace" mode. Therefore, an attempt to read or write from a collection directed with the "replace" set is likely to lead to failure (or unexpected results) while the aggregation operation is in progress.
Other restrictions related to stunned collections and limited collections are noted in the documentation.
source share