-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Sharding
-
None
-
ALL
-
Sharding 17 (07/15/16)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
We have a collection that is sharded on the key "s". There is a compound index on
{ s : 1, s2 :1 }, but no index on just
{ s : 1 }. Everything works fine related to sharding.
However, when running the dataSize command against a mongoS, there is no way to get it to work. Passing it the shard key results in:
db.runCommand({ datasize : "database.collection", keyPattern : { "s" : 1 }, min : { "s" : -999999 }, max : { "s" : 0 }})
{
"estimate" : false,
"ok" : 0,
"errmsg" : "couldn't find valid index containing key pattern",
"$gleStats" : {
"lastOpTime" : Timestamp(0, 0),
"electionId" : ObjectId("000000000000000000000000")
}
}
Passing in the compound key results in:
mongos> db.runCommand({ datasize : "database.collection", keyPattern : { "s" : 1, "s2" : 1 }, min : { "s" : -9999999, "s2" : -9999999 }, max : { "s" : 0, "s2" : 0 }})
{
"code" : 13408,
"ok" : 0,
"errmsg" : "exception: keyPattern must equal shard key"
}
It seems that either mongo shouldn't allow you to shard a collection based on only the prefix of a compound index, or the dataSize command should be smart enough to use the compound index in this situation. I think the latter is preferable.
- related to
-
SERVER-42237 Allow shard key to be prefix of multikey index
-
- Closed
-