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

After movePrimary, db.getCollectionNames() excludes previously existing one-chunk collections

    XMLWordPrintable

    Details

    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      1. Create a sharded cluster (eg. two shards: A and B).
      2. Create a shardable database (eg. test).
      3. Create a sharded one-chunk, collection (eg. test.counter).
      4. Change the primary shard for the database (eg. A => B).
      5. db.getCollectionNames() should not include "test.counter".

      Show
      1. Create a sharded cluster (eg. two shards: A and B). 2. Create a shardable database (eg. test). 3. Create a sharded one-chunk, collection (eg. test.counter). 4. Change the primary shard for the database (eg. A => B). 5. db.getCollectionNames() should not include "test.counter".
    • Case:

      Description

      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" ]

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              esha.maharishi Esha Maharishi
              Reporter:
              stephen.lee Stephen Lee
              Participants:
              Votes:
              7 Vote for this issue
              Watchers:
              16 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: