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

config.collections should reflect if the shard key is unique

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance, Sharding
    • None
    • Sharding

      If you create a unique index to be your shard key index, and then shard without specifying {unique: true}, it shows up as {unique : false} in config.collections

      mongos> db.bar.ensureIndex({a:1}, {unique:true})
      {
      	"raw" : {
      		"Joannas-MacBook-Pro.local:22001" : {
      			"createdCollectionAutomatically" : true,
      			"numIndexesBefore" : 1,
      			"numIndexesAfter" : 2,
      			"ok" : 1
      		}
      	},
      	"ok" : 1
      }
      mongos> sh.shardCollection("test.bar", {a:1})
      { "collectionsharded" : "test.bar", "ok" : 1 }
      mongos> db.getSiblingDB("config").collections.find()
      { "_id" : "test.bar", "lastmodEpoch" : ObjectId("55bf08d75e8b88faa32aeabb"), "lastmod" : ISODate("1970-02-19T17:02:47.296Z"), "dropped" : false, "key" : { "a" : 1 }, "unique" : false }
      

      It would be good if this correctly reflected whether the shard key has guaranteed uniqueness. Above testing was against 3.1.6

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            joanna.cheng@mongodb.com Joanna Cheng
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: