For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

IncompatibleUniqueIndexOnShardedCollection

IncompatibleUniqueIndexOnShardedCollection

An index on a sharded collection has index options that are incompatible with uniqueness requirements.

New in version 8.3. :

{
type: "IncompatibleUniqueIndexOnShardedCollection",
description: "<string>",
details: {
namespace: "<string>",
info: <document>
}
}

ZonesRangeOverlap inconsistency documents contain the following fields:

Field
Type
Description

type

string

Type of inconsistency document. Returns a value of IncompatibleUniqueIndexOnShardedCollection for this inconsistency type.

description

string

Describes the inconsistency found in the metadata.

details

document

Document with additional information on where the inconsistency exists in the database and sharded cluster.

details.namespace

string

Indicates the database and collection where the inconsistency exists.

details.info

document

Information on the incompatible unique index.

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 ZonesRangeOverlap 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
}