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

Trying to shard a collection succeeds even without a unique index

    • ALL

      > use sharded
      > db.unique.drop()
      true
      > db.adminCommand( { shardcollection : "sharded.unique", key:{a:1}})

      { "collectionsharded" : "sharded.unique", "ok" : 1 }

      > db.system.indexes.find()
      { "name" : "id", "ns" : "sharded.foo", "key" :

      { "_id" : 1 }

      , "v" : 0 }
      { "v" : 1, "key" :

      { "_id" : 1 }

      , "ns" : "sharded.unique", "name" : "id" }
      { "v" : 1, "key" :

      { "a" : 1 }

      , "ns" : "sharded.unique", "name" : "a_1" }

      Sharding the collection succeeds and creates two non-unique indexes, one on _id and one on the shard key. It should fail, saying that a unique index is necessary.

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            spencer@mongodb.com Spencer Brody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: