[SERVER-1418] addshard fails with duplicate key error Created: 13/Jul/10  Updated: 12/Jul/16  Resolved: 21/Jul/10

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.5.4
Fix Version/s: 1.5.6

Type: Bug Priority: Minor - P4
Reporter: Bryon Ross Assignee: Alberto Lerner
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

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\" }"
}



 Comments   
Comment by Alberto Lerner [ 21/Jul/10 ]

Author:

{'login': 'alerner', 'name': 'Alberto Lerner', 'email': 'alerner@10gen.com'}

Message: SERVER-1418 Shard names now use padding zeroes
http://github.com/mongodb/mongo/commit/db947047b0231997b0be6ea74ec77f109a2b4fe2

Comment by auto [ 20/Jul/10 ]

Author:

{'login': 'alerner', 'name': 'Alberto Lerner', 'email': 'alerner@10gen.com'}

Message: SERVER-1418 capture scenario in a test
http://github.com/mongodb/mongo/commit/9a96dd0c4bf0d8eb81cce48115657f9a8290e77d

Generated at Thu Feb 08 02:56:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.