Does FsyncLock have timeout in MongoDB?

Is it possible to set timeout for fsynclock or does it have any default value?
I want my operation to fail after 5 minutes if lock fails to get acquired, just wanted to know of there s some value to configure it directly in MongoDB.

Hi Akshaya,

No db.fsyncLock() is a very basic command that does:

  1. Flush all pending writes to disk, then
  2. Lock the mongod from further writes until db.fsyncUnlock() is called, or the server restarted.

So if after a while the command doesn’t return, it means that there are either a lot of dirty data to write to disk, or the disk is too slow to process the writes in a timeframe that you deem reasonable.

Please note that this command is quite risky to run, as it is possible to not be able to unlock the mongod process if the original client that executes the lock command is disconnected from the server for any reason. At that point, you would need to restart the mongod process, which may or may not be feasible depending on your use case.

Best regards,
Kevin