[SERVER-2066] Can't shard a collection with an existing unique index. Error message not helpfull Created: 05/Nov/10  Updated: 06/Dec/22  Resolved: 25/Jan/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.6.3
Fix Version/s: None

Type: Improvement Priority: Trivial - P5
Reporter: laurent laborde Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding
Participants:

 Description   

1) create a collection with a unique index (i created web.explorer with a unique index on "ip")
2) create a sharding environment (configsrv, shardsrv, mongos)
3) connect to mongos/admin :

> db.runCommand(

{ addshard : "xxx.xxx.xxx.xxx:27018" }

);

{ "shardAdded" : "shard0000", "ok" : 1 }

> db.runCommand(

{"enablesharding" : "web"}

)

{ "ok" : 1 }

> db.runCommand({"shardcollection" : "web.explorer", "key" : {"_id" : 1}})
{
"assertion" : "wrong type for BSONElement (unique) 1 != 8",
"assertionCode" : 13111,
"errmsg" : "db assertion failure",
"ok" : 0
}

This message "wrong type for BSONElement (unique) 1 != 8" should me more helpfull.
In this case, a message like "Can't shard a collection with an existing unique index" would be nice.
(i lost many hours to find what was the problem)

thank you.


Generated at Thu Feb 08 02:58:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.