summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2022-11-09 15:06:55 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-09 16:11:10 +0000
commit773ab40e91440e1480d47378f31a5e4f0fadfe72 (patch)
tree15c912761e63077dcf61c8c7583b2a1438061ae5
parent2f3136c12e72cf707e409e6c3df4ef78b285b607 (diff)
downloadmongo-773ab40e91440e1480d47378f31a5e4f0fadfe72.tar.gz
SERVER-67898 Add chunk size in bytes to BalancerCollectionStatusResponse
-rw-r--r--src/mongo/db/s/balancer/balancer.cpp7
-rw-r--r--src/mongo/s/request_types/balancer_collection_status.idl2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp
index 0c1e3282cfc..fdb36b34bdf 100644
--- a/src/mongo/db/s/balancer/balancer.cpp
+++ b/src/mongo/db/s/balancer/balancer.cpp
@@ -1159,7 +1159,12 @@ BalancerCollectionStatusResponse Balancer::getBalancerStatusForNs(OperationConte
uasserted(ErrorCodes::NamespaceNotSharded, "Collection unsharded or undefined");
}
- const auto maxChunkSizeMB = getMaxChunkSizeMB(opCtx, coll);
+
+ const auto maxChunkSizeBytes = getMaxChunkSizeBytes(opCtx, coll);
+ double maxChunkSizeMB = (double)maxChunkSizeBytes / (1024 * 1024);
+ // Keep only 2 decimal digits to return a readable value
+ maxChunkSizeMB = std::ceil(maxChunkSizeMB * 100.0) / 100.0;
+
BalancerCollectionStatusResponse response(maxChunkSizeMB, true /*balancerCompliant*/);
auto setViolationOnResponse = [&response](const StringData& reason,
const boost::optional<BSONObj>& details =
diff --git a/src/mongo/s/request_types/balancer_collection_status.idl b/src/mongo/s/request_types/balancer_collection_status.idl
index 53e86886562..a821222f933 100644
--- a/src/mongo/s/request_types/balancer_collection_status.idl
+++ b/src/mongo/s/request_types/balancer_collection_status.idl
@@ -40,7 +40,7 @@ structs:
strict: false
fields:
chunkSize:
- type: safeInt64
+ type: safeDouble
description: "Configured chunk size in MiB for this collection"
balancerCompliant:
type: bool