Description
Format
{ type: "IncompatibleUniqueIndexOnShardedCollection", description: "<string>", details: { namespace: "<string>", info: <document> } }
IncompatibleUniqueIndexOnShardedCollection inconsistency documents contain the following fields:
Field | Type | Description |
|---|---|---|
| string | Type of inconsistency document. Returns a value of |
| string | Describes the inconsistency found in the metadata. |
| document | Document with additional information on where the inconsistency exists in the database and sharded cluster. |
| string | Indicates the database and collection where the inconsistency exists. |
| document | Information on the incompatible unique index. |
Example
Use the db.adminCommand() method to call the
checkMetadataConsistency command with the checkIndexes
flag set to 1:
db.adminCommand( { checkMetadataConsistency: 1, checkIndexes: 1 } )
The method returns a cursor with a batch of documents showing the
inconsistencies found in the sharding metadata. The example below shows
a cursor with a IncompatibleUniqueIndexOnShardedCollection inconsistency document:
{ cursor: { id: Long("0"), ns: "test.$cmd.aggregate", firstBatch: [ { type: "IncompatibleUniqueIndexOnShardedCollection", description: "Found incompatible index options with uniqueness in a sharded collection", details: { namespace: "test.authors", info: { index: { v: 2, unique: true, key: { author: 1 }, name: "author_1" }, shard: "test-rs1", issue: "Collation must be simple and the shard key must be a prefix of the index key if the index is unique in a sharded collection", shardKey: { author: 1 } } } } ], }, ok: 1 }