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

Improve the interface of `sh.shardCollection`

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.8, 4.0.3
    • Component/s: Sharding
    • None
    • Sharding
    • ALL
    • Hide
      1. Launch a sharded cluster
      2.  sh.enableSharding("test") 
      3.  sh.shardCollection("test.foo", {_id:"hashed"}, {numInitialChunks:128}) 
      4. Error appears even though it should work
      Show
      Launch a sharded cluster sh.enableSharding( "test" ) sh.shardCollection( "test.foo" , {_id: "hashed" }, {numInitialChunks:128}) Error appears even though it should work

      When sharding a collection with a hashed shard key, specifying documented options like numInitialChunks causes the operation to fail.

      sh.shardCollection("test.foo", {_id:"hashed"}, {numInitialChunks:128})
      {
      	"ok" : 0,
      	"errmsg" : "Hashed shard keys cannot be declared unique. It's possible to ensure uniqueness on the hashed field by declaring an additional (non-hashed) unique index on the field.",
      	"code" : 72,
      	"codeName" : "InvalidOptions",
      	"operationTime" : Timestamp(1541185959, 4),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1541185959, 4),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      This is because options parameter is being interpreted as the unique parameter despite the fact that the latter is optional.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: