Docs Menu

db.checkMetadataConsistency()

db.checkMetadataConsistency(options)

Performs a series of consistency checks on sharding metadata for the cluster or database. This method returns a cursor with either all or a batch of the inconsistency results found.

重要

mongosh メソッド

このページでは、mongosh メソッドについて記載しています。ただし、データベースコマンドや Node.js などの言語固有のドライバーのドキュメントには該当しません

データベースコマンドについては、checkMetadataConsistency コマンドを参照してください。

MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。

Run this method after major maintenance operations, such as upgrades and downgrades, or to check if the cluster metadata is inconsistent or corrupted due to bugs in previous releases of MongoDB.

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.

By default, the method checks sharding metadata for the given database. If run on the admin database, it instead checks sharding metadata for the entire cluster.

For more information on the inconsistencies this method searches for, see 不一致のタイプ.

次の値を返します。This method returns a cursor with a documents array, which contains a document for each inconsistency found in the sharding metadata.

このメソッドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです

重要

このコマンドは、M0、M2、M5、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

注意

The checkMetadataConsistency helper is executable only when connecting to mongos. mongod does not support this method.

db.checkMetadataConsistency()メソッドの構文は次のとおりです。

db.checkMetadataConsistency( { <options> } )

The options document can take the following fields and values:

フィールド
タイプ
説明

checkIndexes

ブール値

コマンドがシャーディング メタデータのインデックスもチェックするかどうかを設定します。

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.

cursor

ドキュメント

リターンカーソル を構成します。

cursor.batchSize

integer

Maximum number of sharding metadata inconsistency documents to include in each batch.

To perform consistency checks on a database, call the db.checkMetadataConsistency() method:

use library
db.checkMetadataConsistency()
{
cursorHasMore: false,
documents: [
{
type: "MisplacedCollection",
description: "Unsharded collection found on shard different from database primary shard",
details: {
namespace: "library.authors",
shard: "shard02",
localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4")
}
}
],
}

To perform consistency checks on a cluster, call the db.checkMetadataConsistency() method from the admin database:

use admin
db.checkMetadataConsistency()
{
cursorHasMore: false,
documents: [
{
type: "MisplacedCollection",
description: "Unsharded collection found on shard different from database primary shard",
details: {
namespace: "library.authors",
shard: "shard02",
localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4")
}
}
],
}