Number of locks on a collection

How do i find the number of locks on a collection ?

Hi @Koustav_Chatterjee and welcome in the MongoDB Community :muscle: !

Which version of MongoDB are you running? I will assume the latest 4.4.4 for my answer.

  1. You can activate the profiling which will show you the locks types and modes held during the operation.

More info here:

  1. You can use the admin command db.adminCommand( { lockInfo: 1 } ) on a mongod process, which will give you information on locks that are currently being held or pending.

More info here:

  1. You can also check mongostat output which will tell you about client queues (read/write) and active clients (read/write). It’s not directly linked to the locks as other things can make operation queue (IOPS limitations, …) but it can give you a sense of what is happening.

More info here:

  1. Also not directly related to locks but a few info in there can be related: db.mycollection.stats() will show you all the information about a collection and the WiredTiger storage.

More info here:

What kind of issues are you having that made you look at locks? Happy to help if you share more details.


We are using mmapv1 as mongo engine.
It uses collection level locking even for reads.
If we have n concurrent read requests, each of them has to wait for the previous to finish.
We were more interested to see this on a collection basis.
That is what we are trying to find out.

MMapV1 is now super old and deprecated. Don’t waste your time trying to solve your lock issues and upgrade to the latest version of MongoDB, your performances will improve greatly. There is no other way to fix this.

MongoDB 3.6 will reach End Of Life in April 2021.

1 Like