fsyncUnlock

On this page本页内容

Definition定义

fsyncUnlock

Reduces the lock taken by fsync (with the lock option) on a mongod instance by 1.mongod实例上fsync(使用lock选项)所占用的锁减少1。

Important重要

The fsync lock and fsyncUnlock operations maintain a lock count. fsync lockfsyncUnlock操作保持锁定计数。Each fsync lock operation increments the lock count, and fsyncUnlock decrements the lock count.每个fsync lock操作都会增加锁定计数,而fsyncUnlock会减少锁定计数。

To unlock a mongod instance for writes, the lock count must be zero. 要解锁mongod实例进行写入,锁计数必须为零。That is, for a given number of fsynclock operations, you must issue a corresponding number of fsyncUnlock operations to unlock the instance for writes.也就是说,对于给定数量的fsynclock操作,必须发出相应数量的fsyncUnlock操作来解锁实例以进行写入。

fsyncUnlock is an administrative operation. 是管理操作。Typically you will use fsyncUnlock following a database backup operation.通常,您将在数据库备份操作之后使用fsyncUnlock

To run the fsyncUnlock command, use the db.adminCommand() method:要运行fsyncUnlock命令,请使用db.adminCommand()方法:

db.adminCommand( { fsyncUnlock: 1, comment: <any> } )

The comment field is optional and may contain a comment of any data type.comment字段是可选的,可以包含任何数据类型的注释。

The operation returns a document with the following fields:该操作返回具有以下字段的文档:

Field字段Description描述
infoInformation on the status of the operation操作状态信息
lockCount (New in version 3.4)The number of locks remaining on the instance after the operation.操作后实例上剩余的锁数。
okThe status code.状态代码。
Tip提示

mongosh provides the helper method db.fsyncUnlock().提供了助手方法db.fsyncUnlock()

Examples示例

Consider a situation where db.fsyncLock() has been issued two times. 考虑db.fsyncLock()已发出两次的情况。The following fsyncUnlock operation reduces the locks taken by db.fsyncLock() by 1:以下fsyncUnlock操作将db.fsyncLock()所取的锁减少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. 由于lockCount大于0,mongod实例被锁定,无法写入。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.mongod实例已解锁以进行写入。

←  fsyncgetAuditConfig →