mongodto flush all pending write operations to disk and locks the entire
mongodinstance to prevent additional writes until the user releases the lock with a corresponding
To unlock a
mongodinstance for writes, the lock count must be zero. That is, for a given number of
db.fsyncLock()operations, you must issue a corresponding number of
db.fsyncUnlock()operations to unlock the instance for writes.
db.fsyncLock()has the syntax:
The operation returns a document with the following fields:
info- Information on the status of the operation
lockCount(New in version 3.4)- The number of locks currently on the instance.
seeAlso- Link to the
ok- The status code.
This command provides a simple wrapper around a
fsyncdatabase command with the following syntax:
db.fsyncLock() ensures that the data files are safe to copy using low-level backup utilities such as
mongod started using the copied files contains user-written data that is indistinguishable from the user-written data on the locked
The data files of a locked
mongod may change due to operations such as journaling syncs or WiredTiger snapshots. While this has no affect on the logical data (e.g. data accessed by clients), some backup utilities may detect these changes and emit warnings or fail with errors. For more information on MongoDB- recommended backup utilities and procedures, see MongoDB Backup Methods.
The following operation runs
The operation returns the following status document that includes the
If you run
db.fsyncLock() again, the operation increments the
To unlock the instance for writes, you must run
db.fsyncUnlock() twice to reduce the
lockCount to 0.