[SERVER-18796] printShardingStatus/sh.status doesn't show sharded collections which have no "dropped" field Created: 03/Jun/15  Updated: 05/Feb/16  Resolved: 13/Jul/15

Status: Closed
Project: Core Server
Component/s: Diagnostics, Sharding
Affects Version/s: 3.1.2
Fix Version/s: 3.1.6

Type: Bug Priority: Major - P3
Reporter: Kevin Pulo Assignee: Kevin Pulo
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-18024 Move collection metadata manipulation... Closed
is related to SERVER-19368 Move print.captureAllOutput from prin... Closed
is related to SERVER-19369 Add String.includes() polyfill Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 6 07/17/15
Participants:

 Description   

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:

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.



 Comments   
Comment by Githook User [ 13/Jul/15 ]

Author:

{u'username': u'devkev', u'name': u'Kevin Pulo', u'email': u'kevin.pulo@mongodb.com'}

Message: SERVER-18796: sh.status() show 'dropped:false' colls again

Specifically:

Generated at Thu Feb 08 03:48:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.