fsyncUnlock
On this page
Definition
fsyncUnlock-
Reduces the lock taken by
fsync(with the lock option) on amongodinstance by 1.Important
The
fsynclockandfsyncUnlockoperations maintain a lock count. Eachfsynclockoperation increments the lock count, andfsyncUnlockdecrements the lock count.To unlock a
mongodinstance for writes, the lock count must be zero. That is, for a given number offsynclockoperations, you must issue a corresponding number offsyncUnlockoperations to unlock the instance for writes.fsyncUnlockis an administrative operation. Typically you will usefsyncUnlockfollowing a database backup operation.
Syntax
The command has the following syntax:
db.adminCommand( { fsyncUnlock: 1, comment: <any> } )
The comment field is optional and may contain a comment of any data type.
Results
The operation returns a document with the following fields:
| Field | Description |
|---|---|
info | Information on the status of the operation |
lockCount (New in version 3.4) | The number of locks remaining on the instance after the operation. |
ok | The status code. |
Tip
mongosh provides the helper method db.fsyncUnlock().
Examples
Consider a situation where db.fsyncLock() has been issued two times. The following fsyncUnlock operation reduces the locks taken by db.fsyncLock() by 1:
db.adminCommand( { fsyncUnlock: 1 } )
The operation returns the following document:
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(1), "ok" : 1 }
As the lockCount is greater than 0, the mongod instance is locked against writes. To unlock the instance for writes, run the unlock operation again:
db.adminCommand( { fsyncUnlock: 1 } )
The operation returns the following document:
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(0), "ok" : 1 }
The mongod instance is unlocked for writes.