summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-02-17 08:13:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 14:05:15 +0000
commit3d862d11b0209a57d14de3d9eb829fa67a52176a (patch)
treef07ee751bb2e33fad03cb3d79bbaf3e3eb18bbed
parent21f1f5abf0d7ba00df018716894a70f409eb1d9e (diff)
downloadmongo-3d862d11b0209a57d14de3d9eb829fa67a52176a.tar.gz
SERVER-63721 Defragmentation jstest utils should handle empty shards
(cherry picked from commit 2f45e32577306908cae95220b5c63600b04184e4)
-rw-r--r--jstests/sharding/libs/defragmentation_util.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/jstests/sharding/libs/defragmentation_util.js b/jstests/sharding/libs/defragmentation_util.js
index b62276f71cd..5ef9e1d2c96 100644
--- a/jstests/sharding/libs/defragmentation_util.js
+++ b/jstests/sharding/libs/defragmentation_util.js
@@ -94,7 +94,10 @@ var defragmentationUtil = (function() {
const storageStats = coll.aggregate(pipeline).toArray();
let avgObjSizeByShard = {};
storageStats.forEach((storageStat) => {
- avgObjSizeByShard[storageStat['shard']] = storageStat['storageStats']['avgObjSize'];
+ avgObjSizeByShard[storageStat['shard']] =
+ typeof (storageStat['storageStats']['avgObjSize']) === "undefined"
+ ? 0
+ : storageStat['storageStats']['avgObjSize'];
});
let checkForOversizedChunk = function(
coll, chunk, shardKey, avgObjSize, oversizedChunkThreshold) {