[SERVER-77038] db.<collection>.stats() - BufBuilder attempted to grow .. past the 64MB limit Created: 11/May/23  Updated: 23/Oct/23  Resolved: 23/Oct/23

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

Type: Bug Priority: Major - P3
Reporter: Vinicius Grippa Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-44891 collStats will fail if resulting BSON... Closed
Operating System: ALL
Participants:
Case:

 Description   

Hi,

This might be more of a feature request rather than a bug. If you have a sharded cluster with lots of shards and a collection with several indexes, it is common to see the error following error when running the command from the router:

In this example, I can reproduce the issue with 50 shards and a collection with 50-100 indexes:

mongos> db.getSiblingDB("XXXX").getCollection("YYY").stats()
{
"ok" : 0,
"errmsg" : "BufBuilder attempted to grow() to 67210445 bytes, past the 64MB limit.",
"code" : 13548,
"codeName" : "Location13548",
"operationTime" : Timestamp(1683741378, 653),
"$clusterTime" : {
"clusterTime" : Timestamp(1683741378, 653),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}

So, as Mongo continues to be used over these years, the clusters continue to grow and face architecture limitations. I suggest documenting this limitation or considering it a bug and increasing the limit (ideally, making it configurable through a parameter).

Thanks,



 Comments   
Comment by Eric Sedor [ 23/Oct/23 ]

Apologies Vinicius; it looks like this ticket ended up in an untracked combination of states. I'm deduping this against SERVER-44891, which discusses the limitations of the initial collStats implementation.

The newer implementation of $collStats makes use of a cursor to return results, which overcomes the need to rely on a single document response.

Comment by Eric Sedor [ 11/May/23 ]

Hi vgrippa@gmail.com, is this using the legacy mongo shell? If so can you reproduce using the newer mongosh?

As well, I'd be interested to see if the $collStats aggregation stage gets you a better experience.

Comment by Vinicius Grippa [ 11/May/23 ]

And still talking about the stats() function. If we pass the bufBuilder, we can still face the bson size limitation:

mongos> db.XXXX.stats()
{
"ok" : 0,
"errmsg" : "BSONObj size: 30278307 (0x1CE02A3) is invalid. Size must be between 0 and 16793600(16MB) First element: rs1

Generated at Thu Feb 08 06:34:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.