MongoDb未能构建索引-在索引生成器初始化期间捕获到异常



当我尝试在Atlas服务器上构建复合索引时,它没有显示任何错误,但随后就无法构建索引。

通过shell尝试,我得到了以下内容:

MongoDB Enterprise mongos> db.myCollection.createIndex( {"user_id": "hashed", "identifier": 1, "timestamp": 1} )
{
"raw" : {
"atlas-lgwyih-shard-1/atlas-lgwyih-shard-01-00.kqohn.mongodb.net:27017,atlas-lgwyih-shard-01-01.kqohn.mongodb.net:27017,atlas-lgwyih-shard-01-02.kqohn.mongodb.net:27017" : {
"ok" : 0,
"errmsg" : "Caught exception during index builder initialization my-db.myCollection (c22f2095-1221-43cd-80af-13f2fb3afaff): 1 provided. First index spec: { ns: "my-db.myCollection", v: 2, key: { user_id: "hashed", identifier: 1.0, timestamp: 1.0 }, name: "user_id_hashed_identifier_1_timestamp_1" }",
"code" : 16763,
"codeName" : "Location16763"
}
},
"code" : 16763,
"codeName" : "Location16763",
"ok" : 0,
"errmsg" : "Caught exception during index builder initialization my-db.myCollection (c22f2095-1221-43cd-80af-13f2fb3afaff): 1 provided. First index spec: { ns: "my-db.myCollection", v: 2, key: { user_id: "hashed", identifier: 1.0, timestamp: 1.0 }, name: "user_id_hashed_identifier_1_timestamp_1" }",
"operationTime" : Timestamp(1596400670, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1596400671, 4),
"signature" : {
"hash" : BinData(0,"oh8t17bzKDwsyxv4WzK5suDFP9U="),
"keyId" : NumberLong("6855996587379516447")
}
}
}

到目前为止,我只有集合的默认索引:

MongoDB Enterprise mongos> db.getCollection("myCollection").getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "my-db.myCollection"
}
]

请注意,我希望这个索引按这个顺序排列,因为我想用哈希用户ID上的shard键对集合进行分片。

导致此错误的原因是什么?

啊,由于某种原因,在我的头撞在墙上几个小时后,我只是想确认是否有可能创建一个带有哈希类型的复合索引。事实证明,这是导致错误的原因——希望错误消息更清楚!

此外,正如下面的评论所指出的,这在4.4版本中得到了支持!

最新更新