fsyncUnlock

Definition

  • fsyncUnlock
  • Reduces the lock taken by fsync (with the lock option)on a mongod instance by 1.

Important

The fsync lock and fsyncUnlockoperations maintain a lock count. Each fsync lockoperation increments the lock count, and fsyncUnlockdecrements the lock count.

To unlock a mongod instance for writes, the lock countmust be zero. That is, for a given number of fsynclock operations, you must issue a corresponding number offsyncUnlock operations to unlock the instance forwrites.

fsyncUnlock is an administrative operation. Typicallyyou will use fsyncUnlock following a databasebackup operation.

To run the fsyncUnlock command, use thedb.adminCommand() method:

  1. db.adminCommand( { fsyncUnlock: 1 } )

The operation returns a document with the following fields:

infoInformation on the status of the operationlockCount (New in version 3.4)The number of locks remaining on the instance after the operation.okThe status code.

Tip

The mongo shell provides the helper methoddb.fsyncUnlock().

Examples

Consider a situation where db.fsyncLock() has been issued twotimes. The following fsyncUnlock operation reduces thelocks taken by db.fsyncLock() by 1:

  1. db.adminCommand( { fsyncUnlock: 1 } )

The operation returns the following document:

  1. { "info" : "fsyncUnlock completed", "lockCount" : NumberLong(1), "ok" : 1 }

As the lockCount is greater than 0, the mongod instanceis locked against writes. To unlock the instance for writes, run theunlock operation again:

  1. db.adminCommand( { fsyncUnlock: 1 } )

The operation returns the following document:

  1. { "info" : "fsyncUnlock completed", "lockCount" : NumberLong(0), "ok" : 1 }

The mongod instance is unlocked for writes.