Given a larger (50+) sharded cluster with a collection with a larger (45+) number of indexes, when running the collStats command the result will be a failure due to exceeding the internal BSON document size limit:
mongos> db.runCommand({ collStats : "collection", scale: 1024 }) { "ok" : 0, "errmsg" : "BSONObj size: 17465286 (0x10A7FC6) is invalid. Size must be between 0 and 16793600(16MB) First element: sharded: true", "code" : 10334, "codeName" : "Location10334" }
See https://gist.github.com/alexbevi/dc51c0ce4820f46e46feca06dbdc64bb for reproduction details. Issue appears to originate at https://github.com/mongodb/mongo/blob/81238fa87afbe52a9658547f63c79fac126862f1/src/mongo/s/commands/cluster_coll_stats_cmd.cpp#L207 where the shard results are objectified.
- causes
-
SERVER-44892 getShardDistribution should use $collStats agg stage instead of collStats command
- Closed
- is duplicated by
-
SERVER-77038 db.<collection>.stats() - BufBuilder attempted to grow .. past the 64MB limit
- Closed
- is related to
-
SERVER-44051 getShardDistribution() does not report "Collection XYZ is not sharded" on dropped but previously sharded collections
- Closed
- related to
-
SERVER-33435 Remove the collstats command
- Backlog