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

printShardingStatus/sh.status doesn't show sharded collections which have no "dropped" field

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.6
    • Affects Version/s: 3.1.2
    • Component/s: Diagnostics, Sharding
    • None
    • Fully Compatible
    • ALL
    • Sharding 6 07/17/15

      Commit 4777fb8 from SERVER-18024 changed things so that when a collection is sharded, the entry created in config.collections doesn't have a dropped: false field.

      Unfortunately, printShardingStatus explictly checks for dropped == false, which causes it to not show details for such sharded collections:

      > db.version()
      3.1.2
      > sh.enableSharding("test")
      { "ok" : 1 }
      > sh.shardCollection("test.test", {_id:1})
      { "collectionsharded" : "test.test", "ok" : 1 }
      > sh.status()
      --- Sharding Status ---
        sharding version: {
              "_id" : 1,
              "minCompatibleVersion" : 6,
              "currentVersion" : 7,
              "clusterId" : ObjectId("556eda937eb9e867d4df9553")
      }
        shards:
              {  "_id" : "shard01",  "host" : "genique:31001" }
        balancer:
              Currently enabled:  yes
              Currently running:  no
              Failed balancer rounds in last 5 attempts:  0
              Migration Results for the last 24 hours:
                      No recent migrations
        databases:
              {  "_id" : "test",  "primary" : "shard01",  "partitioned" : true }
      
      > db.getSiblingDB("config").collections.find()
      { "_id" : "test.test", "lastmodEpoch" : ObjectId("556edb397eb9e867d4df9578"), "lastmod" : ISODate("1970-02-19T17:02:47.296Z"), "key" : { "_id" : 1 }, "unique" : false }
      

      The fix is simple:

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
      index f0fc76a..46b5877 100644
      --- a/src/mongo/shell/shardingtest.js
      +++ b/src/mongo/shell/shardingtest.js
      @@ -788,7 +788,7 @@ printShardingStatus = function( configDB , verbose ){
                       configDB.collections.find( { _id : new RegExp( "^" +
                           RegExp.escape(db._id) + "\\." ) } ).
                           sort( { _id : 1 } ).forEach( function( coll ){
      -                        if ( coll.dropped == false ){
      +                        if ( ! coll.dropped ){
                                   output( "\t\t" + coll._id );
                                   output( "\t\t\tshard key: " + tojson(coll.key) );
                                   output( "\t\t\tchunks:" );
      

      Grepping the shell subdirectory for "dropped" shows that this is the only occurrence in the shell JS.

            Assignee:
            kevin.pulo@mongodb.com Kevin Pulo
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: