[SERVER-19075] printShardingStatus/sh.status should show overall chunk count summary Created: 23/Jun/15  Updated: 05/Dec/22  Resolved: 17/Nov/22

Status: Closed
Project: Core Server
Component/s: Sharding, Shell
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kevin Pulo Assignee: [DO NOT USE] Backlog - Sharding EMEA
Resolution: Done Votes: 0
Labels: printShardingStatus, sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding EMEA
Participants:

 Description   

Determining the overall balance of a cluster from the output of sh.status() requires scrolling through all the sharded collections. If there are a lot of sharded collections[1], this is a pain.

Thus the output should include an overall summary of the chunk distribution among the shards.

Either augment the existing "shards" output to include the number of chunks, e.g.:

 > sh.status()
 --- Sharding Status ---
   sharding version: {
         "_id" : 1,
         "minCompatibleVersion" : 6,
         "currentVersion" : 7,
         "clusterId" : ObjectId("556f97135efa42f9f4eaedd1")
 }
   shards:
-        {  "_id" : "shard01",  "host" : "genique:11112" }
-        {  "_id" : "shard02",  "host" : "genique:11113" }
+        {  "_id" : "shard01",  "host" : "genique:11112", numChunks: 34 }
+        {  "_id" : "shard02",  "host" : "genique:11113", numChunks: 22 }
   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:
         ...

Or else add a new top-level "chunks" section (mimicking the per-collection output), e.g.:

 > sh.status()
 --- Sharding Status ---
   sharding version: {
         "_id" : 1,
         "minCompatibleVersion" : 6,
         "currentVersion" : 7,
         "clusterId" : ObjectId("556f97135efa42f9f4eaedd1")
 }
   shards:
         {  "_id" : "shard01",  "host" : "genique:11112" }
         {  "_id" : "shard02",  "host" : "genique:11113" }
   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
+  chunks:
+        shard01    34
+        shard02    22
   databases:
         ...

[1]: Or worse, a lot of sharded collections with just under 20 chunks (or verbose=true was used) and/or shard keys that exceed 1 line in tojson().



 Comments   
Comment by Tommaso Tocci [ 17/Nov/22 ]

Since 6.0 (PM-2323) chunks doesn't necessarily have the same amount of data, in fact they can diverge significantly. For this reason chunks should not be used as a metric to asses cluster balance state, instead $shardedDataDistribution can be used to asses cluster balance state (since 6.0 PM-2934)

Comment by Tommaso Tocci [ 17/Nov/22 ]

Solved by PM-2934

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