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

"show collections" only checks the primary shard

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.6
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide
      mongos> sh.enableSharding("test")
      { "ok" : 1 }
      mongos> sh.shardCollection("test.foo", {_id:1})
      { "collectionsharded" : "test.foo", "ok" : 1 }
      mongos> sh.addShardTag("shard0001", "a")
      mongos> sh.addTagRange("test.foo", {_id: MinKey}, {_id: MaxKey}, "a")
      

      At this point log into the mongod behind "shard0000" and delete the foo collection – there is a stub there from when you first created it.

      Then if you connect back to your mongos, you can get the output as in the Description field

      Show
      mongos> sh.enableSharding( "test" ) { "ok" : 1 } mongos> sh.shardCollection( "test.foo" , {_id:1}) { "collectionsharded" : "test.foo" , "ok" : 1 } mongos> sh.addShardTag( "shard0001" , "a" ) mongos> sh.addTagRange( "test.foo" , {_id: MinKey}, {_id: MaxKey}, "a" ) At this point log into the mongod behind "shard0000" and delete the foo collection – there is a stub there from when you first created it. Then if you connect back to your mongos, you can get the output as in the Description field

      mongos> sh.status()
      --- Sharding Status --- 
        sharding version: {
      	"_id" : 1,
      	"version" : 3,
      	"minCompatibleVersion" : 3,
      	"currentVersion" : 4,
      	"clusterId" : ObjectId("5279b89763d68b8d4364b20c")
      }
        shards:
      	{  "_id" : "shard0000",  "host" : "Joannas-MacBook-Pro.local:27017" }
      	{  "_id" : "shard0001",  "host" : "Joannas-MacBook-Pro.local:27018",  "tags" : [ 	"a" ] }
        databases:
      	{  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
      	{  "_id" : "test",  "partitioned" : true,  "primary" : "shard0000" }
      		test.foo
      			shard key: { "_id" : 1 }
      			chunks:
      				shard0001	1
      			{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : shard0001 Timestamp(2, 0) 
      			 tag: a  { "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } }
      

      I have a collection foo in database test, sharded, primary shard for the db is shard0000, but the collection has a tag range set so it lives on shard0001.

      I can work with this collection, but it does not show up in show collections:

      mongos> db.foo.save({a:1})
      mongos> db.foo.find()
      { "_id" : ObjectId("5279b9e2972221f9a6cf650b"), "a" : 1 }
      mongos> show collections
      system.indexes
      mongos> 
      

      Turning on profiling for both mongoD's backing the shards, when issuing the show collections command I can see queries against test.system.namespaces on the primary shard

      { "op" : "query", "ns" : "test.system.namespaces", "query" : {  }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 2, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(55), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(6), "w" : NumberLong(4) } }, "nreturned" : 2, "responseLength" : 123, "millis" : 0, "ts" : ISODate("2013-11-06T05:25:04.283Z"), "client" : "127.0.0.1", "allUsers" : [ ], "user" : "" }
      { "op" : "query", "ns" : "test.system.namespaces", "query" : {  }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 2, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(50), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(6), "w" : NumberLong(3) } }, "nreturned" : 2, "responseLength" : 123, "millis" : 0, "ts" : ISODate("2013-11-06T05:25:05.650Z"), "client" : "127.0.0.1", "allUsers" : [ ], "user" : "" }
      { "op" : "query", "ns" : "test.system.namespaces", "query" : {  }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 2, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(53), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(6), "w" : NumberLong(3) } }, "nreturned" : 2, "responseLength" : 123, "millis" : 0, "ts" : ISODate("2013-11-06T05:25:07.002Z"), "client" : "127.0.0.1", "allUsers" : [ ], "user" : "" }
      

      But no queries on the other shard.

      I have attached a jstest tag_showcolls.js

            Assignee:
            Unassigned Unassigned
            Reporter:
            joanna.cheng@mongodb.com Joanna Cheng
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: