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

Improve the interface of `sh.shardCollection`

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 3.6.8, 4.0.3
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-sharding Backlog - Sharding Team
              Reporter:
              daniel.hatcher Danny Hatcher
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: