Unable to start a mongod process using mongod --fork as mongo is trying to collectSystemInfo which is very large in size in my system

I tried to launch mongoDB server using mongod --fork and I encountered with the below error message:
{“t”:{“$date”:“2023-11-28T17:49:33.089Z”},“s”:“E”, “c”:“-”, “id”:23077, “ctx”:“main”,“msg”:“Assertion”,“attr”:{“error”:“BSONObjectTooLarge: BSONObj size: 17067964 (0x1046FBC) is invalid. Size must be between 0 and 16793600(16MB) First element: versionString: "Linux version 4.12.14-122.144-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Mon Dec 12 09:21:50 UTC 2022 (bccc371)"”,“file”:“src/mongo/bson/bsonobj.cpp”,“line”:101}}

I tried to explore more about this issue and got to know that mongo is internally trying to collect system information through the function “ProcessInfo::SystemInfo::collectSystemInfo()” and then saves it into a BSON object and then tries to write it in the DB. Some of the system informations which mongo tries to get is : /proc/version, /proc/cpuinfo, /proc/self/mouninfo, /proc/meminfo, etc

I checked the wordcount of these files in the host machine on which we were trying to launch DB. I got the below result :
wc -c /proc/version /proc/cpuinfo /proc/self/mountinfo /proc/meminfo
136 /proc/version
64018 /proc/cpuinfo
11518468 /proc/self/mountinfo
1286 /proc/meminfo
11583908 total

Then, I understood that the issue is due to the large size of “mountinfo”. But now, the issue is how to launch mongoDB without encountering this issue?

So, my questions are :

  1. Is there any way to disable mongod from collecting system info, i.e., is there any possible way to disable calling “ProcessInfo::SystemInfo::collectSystemInfo()” function? If yes, please ellaborate the ways I can do so…
  2. How to launch mongoDB without doing any changes in “/proc/” directory?

Currently, I’m using mongo version 4.4.2 . If the fix to this issue is not available in this release version, please let me know in which release version I’ll be able to fix the issue and how.

You should first try the latest 4.4 (4.4.26 as of this post).

However if that does not resolve the issue, and I suspect it won’t, then you can disable FTDC by adding the below to the mongod configuration file. If you already have a setParameter section append the setting to the existing ones.

https://www.mongodb.com/docs/manual/administration/analyzing-mongodb-performance/#full-time-diagnostic-data-capture

setParameter:
  diagnosticDataCollectionEnabled: false

This seems like a bug to me, if the latest 4.4 does not fix it you can also create an issue at https://jira.mongodb.org

Thanks Chris for helping me. But adding the “setParameter” to the mongod configuration file doesn’t solve the issue.
mongod is trying to open /proc/* now too… which is being done in ProcessInfo::SystemInfo::collectSystemInfo() function.

Below are some lines of “strace” with mongod --fork command.
open(“/proc/version”, O_RDONLY) = 4
*fstat(4, {st_mode=S_IFREG|0444, st_size=0, …}) = 0 *
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb2b275000
*read(4, "Linux version "…, 1024) = 136 *
close(4)

Please let me know any other way through which I can disable calling function which collects system information.

Thanks,
Nidhi

I dug in a little bit deeper also. I don’t think this is something that can be worked around with configuration options.

How large is the the output of /proc/self/mountinfo ?

Hi Chris,
wc -c /proc/version /proc/cpuinfo /proc/self/mountinfo /proc/meminfo
136 /proc/version
64018 /proc/cpuinfo
11518468 /proc/self/mountinfo
1286 /proc/meminfo
11583908 total
Above is the details of /proc/*

/proc/self/mountinfo size is 11MB… and as per my understanding now, BSON obj containing system info should not be more than 16MB in my case…

If it’s more than 16MB, how can we launch mongoDB successfully?? and if it’s not the case, what could be other reason that I’m getting below error?
{“t”:{“$date”:“2023-11-28T17:49:33.089Z”},“s”:“E”, “c”:“-”, “id”:23077, “ctx”:“main”,“msg”:“Assertion”,“attr”:{“error”:“BSONObjectTooLarge: BSONObj size: 17067964 (0x1046FBC) is invalid. Size must be between 0 and 16793600(16MB) First element: versionString: “Linux version 4.12.14-122.144-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Mon Dec 12 09:21:50 UTC 2022 (bccc371)””,“file”:“src/mongo/bson/bsonobj.cpp”,“line”:101}}

At last, my aim is to successfully launch mongod process using mongod --fork command.

Thanks,
Nidhi

I recommend you create an issue on https://jira.mongodb.org/ while unusual in size the generation of such a large document is foreseeable and should be limited.

As a workaround you could try running MongoDB in a container and, of course, there is MongoDB Atlas.

This does seem unusually large. What is creating so many mounts, or put another way how would someone reproduce this ?