When mongoDB write is occurring then a read must wait or not wait. when mongoDB going to write some doc in mongodb at that time write lock happen and other thread try to read other docs then it should wait until write lock release or not. is there any dependency between all read and write locks
From the docs.
MongoDB uses a readers-writer lock that allows concurrent reads access to a database but gives exclusive access to a single write operation.
When a read lock exists, many read operations may use this lock. However, when a write lock exists, a single write operation holds the lock exclusively, and no other read or write operations may share the lock.
Locks are “writer greedy,” which means write locks have preference over reads. When both a read and write are waiting for a lock, MongoDB grants the lock to the write.
To answer your question:
So 'n' number of reads can happen in parallel, and all reads/writes are blocked when a write happens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With