I'm planning to run
Bulk.find.remove() on a very big collection. (1.2TB).
Will it block inserting or updating other records (which are not a part of the above
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
The short answer is: No, you will not be blocked.
When performing multi-document write operations, whether through a single write operation or multiple write operations, other operations may interleave.
The long explains are:
Collection is granular level (or the resource).
Whenever there is a write operation, Exclusive (X) lock mode must be applied on the resource.
As Collection is the resource in this scenario, Exclusive (X) lock mode must be applied on the Collection.
For all outer levels : Database, Global; Intent Exclusive (IX) must be applied.
When a write operation is triggered for a Collection, the control must do the following series of locks :
The MongoD instance must be locked in Intent Exclusive (IX) lock mode, with an intent to apply write operation in a granular level (Database / Collection / Document). The Database must be locked in Intent Exclusive (IX) lock mode, with an intent to apply write operation in a granular level (Collection / Document). The Collection must be locked in Exclusive (X) lock mode, to apply write operation on the Collection.
You can find more info in the following links:
https://docs.mongodb.com/manual/core/write-operations-atomicity/ https://docs.mongodb.com/manual/faq/concurrency/ https://docs.mongodb.com/manual/reference/method/Bulk.find.remove/ https://www.tutorialkart.com/mongodb/mongodb-locks/