diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-05-24 11:28:20 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-25 20:00:04 +0000 |
commit | c09e27d0ea8b535a3a766924c141116c801f641a (patch) | |
tree | cf2dc854ed93fe67900a0b16e3049c06e4e923cc /src/mongo/s/commands | |
parent | 3637dce904cc334f7e72dcf23516f18c7b815eda (diff) | |
download | mongo-c09e27d0ea8b535a3a766924c141116c801f641a.tar.gz |
SERVER-56883 Fix db.collection.stats() error on mongos when calling on timeseries collection
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r-- | src/mongo/s/commands/cluster_coll_stats_cmd.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp index 8dd6772c8d9..fe30992c35f 100644 --- a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp +++ b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp @@ -168,7 +168,10 @@ public: // We don't know the order that we will encounter the count and size, so we save them // until we've iterated through all the fields before updating unscaledCollSize - const auto shardObjCount = static_cast<long long>(res["count"].Number()); + // Timeseries bucket collection does not provide 'count' or 'avgObjSize'. + BSONElement countField = res.getField("count"); + const auto shardObjCount = + static_cast<long long>(!countField.eoo() ? countField.Number() : 0); for (const auto& e : res) { StringData fieldName = e.fieldNameStringData(); @@ -192,6 +195,7 @@ public: counts[e.fieldName()] += e.numberLong(); } else if (fieldName == "avgObjSize") { const auto shardAvgObjSize = e.numberLong(); + uassert(5688300, "'avgObjSize' provided but not 'count'", !countField.eoo()); unscaledCollSize += shardAvgObjSize * shardObjCount; } else if (fieldName == "maxSize") { const auto shardMaxSize = e.numberLong(); |