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

Cannot insert document with MaxKey shard key

    • Query Execution
    • ALL

      mongos> db.adminCommand({ enableSharding: 'test' })
      mongos> db.adminCommand({ shardCollection: 'test.user', key: { x: 1 }})
      mongos> db.user.insert({ x: MaxKey })
      WriteCommandError({
      	"ok" : 0,
      	"errmsg" : "Cannot target single shard using key { x: MaxKey }",
      	"code" : 61,
      	"codeName" : "ShardKeyNotFound",
      	"operationTime" : Timestamp(1542658417, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1542658417, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      })
      

      This could be a potential edge case where { x: MaxKey } was inserted before collection was sharded and it would practically be invisible to the sharded cluster (since chunk upper bound is exclusive and migrations and versioned queries will ignore it).

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: