对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

InconsistentIndex

InconsistentIndex

两个不同的分片上存在包含不同元数据的索引,或者某些分片上缺少特定索引。

7.0版本新增。:

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

InconsistentIndex 不一致文档包含以下字段:

字段
类型
说明

type

字符串

不一致文档的类型。 为此不一致类型返回值InconsistentIndex

description

字符串

描述在元数据中发现的不一致之处。

details

文档

包含有关数据库和分片集群中哪些位置存在不一致的附加信息的文档。

details.namespace

字符串

指示存在不一致的数据库和collection。

details.info

文档

有关不一致索引的信息。

使用db.adminCommand()方法调用checkMetadataConsistency命令:

db.adminCommand( {
checkMetadataConsistency: 1,
checkIndexes: true
} )

该方法返回一个游标,其中包含批处理文档,显示分片元数据中发现的不一致之处。以下示例显示了具有 InconsistentIndex 不一致文档的游标:

{
cursor: {
id: Long("0"),
ns: "test.$cmd.aggregate",
firstBatch: [
{
type: "InconsistentIndex",
description: "Found an index of a sharded collection that is inconsistent between different shards",
details: {
namespace: "test.authors",
info: {
missingFromShards: [
"shard-rs1"
],
inconsistentProperties: [ ],
indexName: "index1"
}
}
}
],
},
ok: 1
}

在此页面上