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

addshard fails with duplicate key error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.5.6
    • Affects Version/s: 1.5.4
    • Component/s: Sharding
    • None
    • ALL

      If two or more shards are added and then the first shard is removed, future addshard commands will fail with a duplicate key error.

      > use admin
      switched to db admin
      > db.runCommand(

      {listshards : 1}

      )

      { "shards" : [ ], "ok" : 1 }

      > db.runCommand(

      {addshard : "server1:27018"}

      )

      { "added" : "server1:27018", "ok" : 1 }

      > db.runCommand(

      {addshard : "server2:27018"}

      )

      { "added" : "server2:27018", "ok" : 1 }

      > db.runCommand(

      {listshards : 1}

      )
      {
      "shards" : [

      { "_id" : "shard0", "host" : "server1:27018" }

      ,

      { "_id" : "shard1", "host" : "server2:27018" }

      ],
      "ok" : 1
      }
      > db.runCommand(

      {removeshard : "server1:27018"}

      )
      {
      "msg" : "draining started successfully",
      "state" : "started",
      "shard" : "server1:27018",
      "ok" : 1
      }
      > db.runCommand(

      {removeshard : "server1:27018"}

      )
      {
      "msg" : "removeshard completed successfully",
      "state" : "completed",
      "shard" : "server1:27018",
      "ok" : 1
      }
      > db.runCommand(

      {listshards : 1}

      )
      {
      "shards" : [

      { "_id" : "shard1", "host" : "server2:27018" }

      ],
      "ok" : 1
      }
      > db.runCommand(

      {addshard : "server3:27018"}

      )
      {
      "ok" : 0,
      "errmsg" : "E11000 duplicate key error index: config.shards.$id dup key: { : \"shard1\" }"
      }

            Assignee:
            alerner Alberto Lerner
            Reporter:
            bryonr Bryon Ross
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: