Docs Menu
Docs Home
MongoDB Manual
/ / /


On this page

  • Definition
  • Compatibility
  • Syntax
  • Example

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.


mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the checkMetadataConsistency command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

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 Inconsistency Types.

Returns:This method returns a cursor with a documents array, which contains a document for each inconsistency found in the sharding metadata.

This method is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud


This command is supported in all MongoDB Atlas clusters. For information on all commands, see Unsupported Commands.

The db.collection.checkMetadataConsistency() method has the following syntax:

db.collection.checkMetadataConsistency( { <options> } )

The options document can take the following fields and values:


Sets whether the command also checks indexes in sharding metadata.

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.

Configures the return cursor.
Maximum number of sharding metadata inconsistency documents to include in each batch.
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")
← db.checkMetadataConsistency()