Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2066

Can't shard a collection with an existing unique index. Error message not helpfull

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: 1.6.3
    • Component/s: Sharding
    • None
    • Sharding
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            ker2x laurent laborde
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: