Definição
fsyncUnlockReduz a contagem de bloqueios no servidor ou cluster. To enable write operations, the lock count must be zero.
A partir de MongoDB 7.1 (também disponível a partir de 7.0.2, 6.0.11 e 5.0.22) os comandos
fsyncefsyncUnlockpodem ser executados emmongospara bloquear e desbloquear um cluster fragmentado.Use este comando para desbloquear gravações depois de concluir uma operação de backup.
Importante
Servers maintain an fsync lock count. The
fsynccommand with thelockfield set totrueincrements the lock count while thefsyncUnlockcommand decrements it. To enable writes on a locked server or cluster, call thefsyncUnlockcommand until the lock count reaches zero.fsyncUnlockis an administrative operation. Typically you will usefsyncUnlockfollowing a database backup operation.Dica
In
mongosh, this command can also be run through thedb.fsyncUnlock()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
Compatibilidade
Esse comando está disponível em implantações hospedadas nos seguintes ambientes:
MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB
MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB
Sintaxe
O comando tem a seguinte sintaxe:
db.adminCommand( { fsyncUnlock: 1, comment: <any> } )
O campo comment é opcional e pode conter um comentário de qualquer tipo de dados.
Resultados
A operação retorna um documento com os seguintes campos:
Campo | Descrição |
|---|---|
| Informações sobre o status da operação |
| O número de bloqueio restantes na instância após a operação. |
| O código de status. |
Exemplos
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 } )
A operação retorna o seguinte documento:
{ "info" : "fsyncUnlock completed", "lockCount" : Long(1), "ok" : 1 }
As the lockCount is greater than 0, the mongod instance is locked against writes. Para desbloquear a instância para gravações, execute a operação de desbloqueio novamente:
db.adminCommand( { fsyncUnlock: 1 } )
A operação retorna o seguinte documento:
{ "info" : "fsyncUnlock completed", "lockCount" : Long(0), "ok" : 1 }
A instância mongod está desbloqueada para gravações.