|
After removing one RS member in a shard, MongoS updates config.shards but keeps the stale shard string in the explain() output.
Create a new sharded collection with a single record:
mongos> sh.enableSharding("beep")
|
{ "ok" : 1 }
|
mongos> sh.shardCollection("beep.beeps",{_id:1})
|
{ "collectionsharded" : "beep.beeps", "ok" : 1 }
|
mongos> use beep
|
switched to db beep
|
mongos> db.beeps.insert({x:1})
|
WriteResult({ "nInserted" : 1 })
|
mongos> db.beeps.find()
|
{ "_id" : ObjectId("5463ac6986131a1d5750adcd"), "x" : 1 }
|
mongos> db.beeps.find({ "_id" : ObjectId("5463ac6986131a1d5750adcd")}).explain()
|
{
|
"clusteredType" : "ParallelSort",
|
"shards" : {
|
"db_0/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-2.mralex.9768.mongodbdns.com:27000" : [
|
{
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscannedObjects" : 1,
|
"nscanned" : 1,
|
"indexOnly" : false,
|
"millis" : 0,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"server" : "AlexMMSADemo-0.mralex.9768:27000"
|
}
|
]
|
},
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscanned" : 1,
|
"nscannedObjects" : 1,
|
"millisShardTotal" : 0,
|
"millisShardAvg" : 0,
|
"numQueries" : 1,
|
"numShards" : 1,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"millis" : 0
|
}
|
mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: {
|
"_id" : 1,
|
"version" : 4,
|
"minCompatibleVersion" : 4,
|
"currentVersion" : 5,
|
"clusterId" : ObjectId("5463abcdd77c8abb282138a4")
|
}
|
shards:
|
{ "_id" : "db_0", "host" : "db_0/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-2.mralex.9768.mongodbdns.com:27000" }
|
{ "_id" : "db_1", "host" : "db_1/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27001,AlexMMSADemo-0.mralex.9768.mongodbdns.com:27002,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27001" }
|
databases:
|
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
|
{ "_id" : "beep", "partitioned" : true, "primary" : "db_0" }
|
beep.beeps
|
shard key: { "_id" : 1 }
|
chunks:
|
db_0 1
|
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : db_0 Timestamp(1, 0)
|
Remove one replica set node and see that the shard description in the explain() output still has the old node in it:
mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: {
|
"_id" : 1,
|
"version" : 4,
|
"minCompatibleVersion" : 4,
|
"currentVersion" : 5,
|
"clusterId" : ObjectId("5463abcdd77c8abb282138a4")
|
}
|
shards:
|
{ "_id" : "db_0", "host" : "db_0/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27000" }
|
{ "_id" : "db_1", "host" : "db_1/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27001,AlexMMSADemo-0.mralex.9768.mongodbdns.com:27002,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27001" }
|
databases:
|
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
|
{ "_id" : "beep", "partitioned" : true, "primary" : "db_0" }
|
beep.beeps
|
shard key: { "_id" : 1 }
|
chunks:
|
db_0 1
|
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : db_0 Timestamp(1, 0)
|
|
mongos> db.beeps.find({ "_id" : ObjectId("5463ac6986131a1d5750adcd")}).explain()
|
{
|
"clusteredType" : "ParallelSort",
|
"shards" : {
|
"db_0/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-2.mralex.9768.mongodbdns.com:27000" : [
|
{
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscannedObjects" : 1,
|
"nscanned" : 1,
|
"indexOnly" : false,
|
"millis" : 0,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"server" : "AlexMMSADemo-0.mralex.9768:27000"
|
}
|
]
|
},
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscanned" : 1,
|
"nscannedObjects" : 1,
|
"millisShardTotal" : 0,
|
"millisShardAvg" : 0,
|
"numQueries" : 1,
|
"numShards" : 1,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"millis" : 0
|
}
|
Wait some time to be sure:
mongos> new Date()
|
ISODate("2014-11-12T18:57:44.499Z")
|
mongos> new Date()
|
ISODate("2014-11-12T18:59:23.038Z")
|
mongos> db.beeps.find({ "_id" : ObjectId("5463ac6986131a1d5750adcd")}).explain()
|
{
|
"clusteredType" : "ParallelSort",
|
"shards" : {
|
"db_0/AlexMMSADemo-0.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-1.mralex.9768.mongodbdns.com:27000,AlexMMSADemo-2.mralex.9768.mongodbdns.com:27000" : [
|
{
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscannedObjects" : 1,
|
"nscanned" : 1,
|
"indexOnly" : false,
|
"millis" : 0,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"server" : "AlexMMSADemo-0.mralex.9768:27000"
|
}
|
]
|
},
|
"cursor" : "IDCursor",
|
"n" : 1,
|
"nscanned" : 1,
|
"nscannedObjects" : 1,
|
"millisShardTotal" : 0,
|
"millisShardAvg" : 0,
|
"numQueries" : 1,
|
"numShards" : 1,
|
"indexBounds" : {
|
"_id" : [
|
[
|
ObjectId("5463ac6986131a1d5750adcd"),
|
ObjectId("5463ac6986131a1d5750adcd")
|
]
|
]
|
},
|
"millis" : 0
|
}
|
mongos>
|
|