[SERVER-21225] Better error messaging when attempting to add a shard with the same name or members as an existing shard Created: 30/Oct/15  Updated: 16/May/16  Resolved: 10/May/16

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.3.6

Type: Task Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: Dianna Hohensee (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 10 (02/19/16), Sharding 11 (03/11/16), Sharding 12 (04/01/16), Sharding 13 (04/22/16), Sharding 14 (05/13/16)
Participants:

 Description   

Currently when you try to add a shard with the same name as an existing shard you get a duplicate key error, and if you try to add a shard with the same host(s) as an existing shard you get a not master error

sh.status()
--- Sharding Status --- 
  sharding version: {
	"_id" : 1,
	"minCompatibleVersion" : 5,
	"currentVersion" : 6,
	"clusterId" : ObjectId("55dcf519b004ad14bc014bef")
}
  shards:
	{  "_id" : "rs1",  "host" : "rs1/ubuntu:20001,ubuntu:20002,ubuntu:20003" }
	{  "_id" : "rs2",  "host" : "rs2/ubuntu:30001,ubuntu:30002,ubuntu:30003",  "draining" : true }
  balancer:
	Currently enabled:  yes
	Currently running:  yes
		Balancer lock taken at Thu Sep 03 2015 18:20:26 GMT-0400 (EDT) by ubuntu:27017:1441318568:1804289383:Balancer:846930886
	Failed balancer rounds in last 5 attempts:  0
	Migration Results for the last 24 hours: 
		No recent migrations
  databases:
	{  "_id" : "temp",  "primary" : "rs1",  "partitioned" : false }
	{  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
 
mongos> sh.addShard('rs1/ubuntu:20001')
{
	"ok" : 0,
	"errmsg" : "E11000 duplicate key error collection: config.shards index: _id_ dup key: { : \"rs1\" }",
	"code" : 11000
}
mongos> sh.addShard('rs3/ubuntu:20001')
{ "ok" : 0, "errmsg" : "No master found for set rs3", "code" : 10107 }



 Comments   
Comment by Githook User [ 10/May/16 ]

Author:

{u'username': u'DiannaHohensee', u'name': u'Dianna Hohensee', u'email': u'dianna.hohensee@10gen.com'}

Message: SERVER-21225 refactoring validateHostAsShard to improve addShard behavior and error messaging
Branch: master
https://github.com/mongodb/mongo/commit/f542309793c5e9ed9aa46c5589b9e0b2b62084bc

Comment by Githook User [ 07/Apr/16 ]

Author:

{u'username': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: Revert "SERVER-21225 refactoring validateHostAsShard to improve addShard behavior and error messaging"

This reverts commit 6178203a1cfecd6a9fe3af68e2bab73544d486d7.
unittest suite is hanging.
Branch: master
https://github.com/mongodb/mongo/commit/b44fd5925e6b2899a81e4c1b7f13087a665f8c6e

Comment by Githook User [ 06/Apr/16 ]

Author:

{u'username': u'DiannaHohensee', u'name': u'Dianna Hohensee', u'email': u'dianna.hohensee@10gen.com'}

Message: SERVER-21225 refactoring validateHostAsShard to improve addShard behavior and error messaging
Branch: master
https://github.com/mongodb/mongo/commit/6178203a1cfecd6a9fe3af68e2bab73544d486d7

Comment by Spencer Brody (Inactive) [ 07/Mar/16 ]

I would reword the first message slightly to something like "Replica set <replset name> is already a part of the cluster as shard <shard name>" - the user probably doesn't know anything about the 'shards' collection, the key point is that it's already a shard.

As for the second message, can we actually tell the user that the problem is that the host is already a part of another shard, rather than saying we can't contact it?

Comment by Dianna Hohensee (Inactive) [ 07/Mar/16 ]

Spencer, is this update satisfactory?

mongos> sh.status()
config.locks collection empty or missing. be sure you are connected to a mongos
--- Sharding Status ---
  sharding version: {
	"_id" : 1,
	"minCompatibleVersion" : 5,
	"currentVersion" : 6,
	"clusterId" : ObjectId("56ddf344a779b83d41de74f6")
}
  shards:
	{  "_id" : "test-rs0",  "host" : "test-rs0/Dianna:20000,Dianna:20001,Dianna:20002" }
	{  "_id" : "test-rs1",  "host" : "test-rs1/Dianna:20003,Dianna:20004,Dianna:20005" }
  active mongoses:
	"3.3.2-122-g7652290" : 1
  balancer:
	Currently enabled:  no
	Currently running:  no
	Failed balancer rounds in last 5 attempts:  0
	Migration Results for the last 24 hours:
		No recent migrations
  databases:
 
mongos> sh.addShard('test-rs0/Dianna:20000')
{
	"ok" : 0,
	"errmsg" : "Set replica set 'test-rs0' is already in the shards collection",
	"code" : 96
}
mongos> sh.addShard('test-rs6/Dianna:20000')
{
	"ok" : 0,
	"errmsg" : "None of the hosts for replica set test-rs6 could be contacted.",
	"code" : 71
}
mongos>

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