db.collection.checkMetadataConsistency()
Nesta página
Definição
db.collection.checkMetadataConsistency(options)
Performs a series of consistency checks on sharding metadata for the collection. The method returns a cursor with either all or a batch of the inconsistency results found.
Importante
Método mongosh
Esta página documenta um método
mongosh
. Esta não é a documentação para comandos de banco de dados nem drivers específicos de linguagem, como Node.js.Para o comando do banco de dados, consulte o comando
checkMetadataConsistency
.Para drivers de API do MongoDB, consulte a documentação do driver do MongoDB específica da linguagem.
Run this method after major maintenance operations, such as upgrades and downgrades, to check the state of the catalog.
By default, the method does not check indexes for consistency across the shards. Index checks can return false positive inconsistencies if they run concurrent with operations that create, delete, or modify indexes. To check indexes with this method, set the
checkIndexes
option.For more information on the inconsistencies this method checks for, see Tipos de inconsistência.
Retorna: This method returns a cursor with a documents
array, which contains a document for each inconsistency found in the sharding metadata.
Compatibilidade
Esse método está disponível em implantações hospedadas nos seguintes ambientes:
MongoDB Atlas: o serviço totalmente gerenciado para implantações do MongoDB na nuvem
Importante
Esse comando não é suportado em clusters M0, M2, M5 e Flex. Para obter mais informações, consulte Comandos não suportados.
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
Observação
The checkMetadataConsistency
helper is executable only when connecting to
mongos
. mongod
does not support this method.
Sintaxe
O método db.collection.checkMetadataConsistency()
tem a seguinte sintaxe:
db.collection.checkMetadataConsistency( { <options> } )
The options
document can take the following fields and values:
Campo | Tipo | Descrição |
---|---|---|
| booleano | Define se o comando também verifica índices em metadados de fragmentação. By default, this operation is disabled, because if it can return false positives inconsistencies when run concurrent with operations that create, delete, or modify indexes. Only check indexes at times when you know these operations are unlikely to occur. |
| documento | Configura o cursor de retorno. |
| inteiro | Maximum number of sharding metadata inconsistency documents to include in each batch. |
Exemplo
db.authors.checkMetadataConsistency()
{ cursorHasMore: false, documents: [ { type: "MisplacedCollection", description: "Unsharded collection found on shard different from database primary shard", details: { namespace: "test.authors", shard: "shard02", localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4") } } ], }