I am no expert but I vaguely remember reading somewhere that for long
running write operations like you have, mongo "yields" for others so
other operations can also grab the lock to do something.
Quoting megha garg <
megha...@gmail.com>:
> Hi,
>
> I have some doubt about mongodb locks.
>
> I am using mongo 2.6.6 and performing bulk insert on one collection with
> below command:-
>
>> use test
>> for(i=1;i<=20000000;i++) { db.test1.insert({a:i}) }
>
> The above command acquires write lock on test database. According to the
> documentation's below statement i will not be able to acquire read/write
> lock on test database till this query is running:-
>
> 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.
>
> But i am able to run my find query during this time period on test1
> collection of test database :-
>
>> use test
>> db.test1.find()
>
>
> Also, write on same collection, test1 during this time period is also
> working:-
>
>> use test
>> db.test1.insert({c:33})
> WriteResult({ "nInserted" : 1 })
>
>
> The documentation says write lock will block other read/write locks, so how
> my above read and write queries are running??
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
>
http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to
mongodb-user...@googlegroups.com.
> To post to this group, send email to
mongod...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/mongodb-user/bcfbb0c9-34cd-4a7b-bc8a-31a379b2f3c3%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
-DJ
609-309-5340