When server is started, mongotop works. After a few hours/days, mongotop fails. The error shown is of the form:
2022-07-01T01:38:14.747+0000 Failed: BSONObj size: 59797193 (0x3906EC9) is invalid. Size must be between 0 and 16793600(16MB) First element: note: “all times in microseconds”
If the mongod service is restarted, mongotop works again. But, again after a few hours/days, mongotop fails again with the same error above.
Another case is, when a script is run to check document object size across all documents in all collections in all databases, script fails after a while. It is Never always the same database/collection/document.
Please help in understanding why mongotop is failing randomly and make it work reliably without any failure.
This error is raising because it’s hitting more than the max size of BSONObj i.e., 16 MB and the mongotop command currently returns its output as a single BSON document so the result is limited to 16MB and here it’s 60MB.
So, restarting the mongod clears the in-memory information and it works again!
However, to better understand the issue could you please provide us a few details:
Unfortunately, I think you’re hitting the issue SERVER-6627, where in a very large deployment, the output of the top command (which mongotop relies on) can get past the 16MB BSON size limitation. I would encourage you to comment & upvote on the ticket to help the development team prioritize this issue.
In the meantime, I think you can use the output of db.currentOp() as a workaround.
Please let us know if you have any follow-up questions!
It returns a cursor that can build a document with details found in db.currentOp(). The cursor goes over documents each of which should not be greater than 16MB. But, the aggregate will build a document that has No size restrictions. Can give all info in mongotop, plus more.