Reputation: 81
I am using mongo 3.2 and some queries to a collection I have that is rarely written to - have to wait for a global lock (on the order of 100's of milliseconds).
I thought writes may lock documents or collections - but why would a read query on a small collection have to wait for a 'global lock'? Even if the rest of the system is getting tons of writes on other collections.
Can someone point me in the direction for docs on what causes a global lock to occur?
Upvotes: 2
Views: 3863
Reputation: 406
Check out the Concurrency FAQ. In particular, that page highlights the intent locking scheme that requires every operation to take the global lock in intent mode, in case another operation needs to prevent any reads by taking the global lock in a regular (non-intent) mode. The Does a MongoDB Operation Ever Lock More Than One Database? section details some operations that will take the global lock in a mode that will conflict with normal reads or writes. There is also a section titled How do I see the status of Locks on my mongod instances? that might help you figure out which locks are conflicting with your operations.
Upvotes: 3