|
db.getCollectionNames() on mongos essentially reflects db.getCollectionNames() output from the mongod of the database's primary shard. If small, one-chunk collections are created prior to a movePrimary, db.getCollectionNames() query the newly changed primary shard which doesn't report the existence of those small, one-chunk collections.
mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: { "_id" : 1, "version" : 3 }
|
shards:
|
{ "_id" : "s1", "host" : "s1/localhost:10000,localhost:10001,localhost:10002", "tags" : [ "a" ] }
|
{ "_id" : "s2", "host" : "s2/localhost:20000,localhost:20001,localhost:20002", "tags" : [ "b" ] }
|
databases:
|
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
|
{ "_id" : "test", "partitioned" : true, "primary" : "s2" }
|
|
mongos> db.counter.insert({a:1})
|
mongos> db.counter.ensureIndex({a:1})
|
mongos> sh.shardCollection("test.counter",{a:1})
|
{ "collectionsharded" : "test.counter", "ok" : 1 }
|
mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: { "_id" : 1, "version" : 3 }
|
shards:
|
{ "_id" : "s1", "host" : "s1/localhost:10000,localhost:10001,localhost:10002", "tags" : [ "a" ] }
|
{ "_id" : "s2", "host" : "s2/localhost:20000,localhost:20001,localhost:20002", "tags" : [ "b" ] }
|
databases:
|
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
|
{ "_id" : "test", "partitioned" : true, "primary" : "s2" }
|
test.counter chunks:
|
s2 1
|
{ "a" : { $minKey : 1 } } -->> { "a" : { $maxKey : 1 } } on : s2 Timestamp(1000, 0)
|
|
mongos> db.getCollectionNames()
|
[ "counter", "system.indexes" ]
|
mongos> db.adminCommand({movePrimary:"test",to:"s1"})
|
{
|
"primary " : "s1:s1/localhost:10000,localhost:10001,localhost:10002",
|
"ok" : 1
|
}
|
mongos> db.getCollectionNames()
|
[ "system.indexes" ]
|
mongos> db.adminCommand({movePrimary:"test",to:"s2"})
|
{
|
"primary " : "s2:s2/localhost:20000,localhost:20001,localhost:20002",
|
"ok" : 1
|
}
|
mongos> db.getCollectionNames()
|
[ "counter", "system.indexes" ]
|
|