I build my own mongodb container and the Dockerfile contains following:
...
FROM mongo:latest
...
RUN mongod \
--fork \
--config /home/mongodb/mongodb.conf
...
When version 7, the above RUN command has no problem. But, when mongodb moved to version 8, I get the following error:
=> ERROR [stage-1 10/11] RUN mongod --fork --config /home/mon 0.3s
------
> [stage-1 10/11] RUN mongod --fork --config /home/mongodb/mongodb.conf:
0.224 7 src/third_party/tcmalloc/dist/tcmalloc/internal/sysinfo.cc:123] CHECK in NumPossibleCPUsNoCache: cpus.has_value() (false)
0.225 Aborted
------
ERROR: failed to solve: executor failed running [/bin/sh -c mongod --fork --config /home/mongodb/mongodb.conf]: exit code: 134
It happens on my certain environment. Is there a way to bypass/skip the check?
The mongodb.conf is like the following:
storage:
dbPath: /home/mongodb/data
systemLog:
destination: file
path: /home/mongodb/logs/mongodb.log
net:
tls:
mode: requireTLS
CAFile: /home/mongodb/certs/cert.pem
certificateKeyFile: /home/mongodb/certs/mongodb_tls.pem
allowConnectionsWithoutCertificates: true
The “CHECK in NumPossibleCPUsNoCache” error typically occurs when TCMalloc is unable to access system information about CPU cores. One possible hypothesis is that OS hardening policy on your host is restricting access to certain system files in this case /sys/devices/system/cpu/possible which contains information about CPUs that have been allocated resources and can be brought online if they are present in the system.
Starting in MongoDB 8.0, MongoDB uses an upgraded version of TCMalloc that uses per-CPU caches i.e to say TCMalloc implements a per-CPU caching mode, where each logical CPU in the system has its own cache for memory allocation. The information from the file /sys/devices/system/cpu/possible helps TCMalloc determine how many CPU caches to create.
Thanks to explain.
Is there a way to bypass the check, so that I can use 8.0 to build my own mongodb container?
I do not think there is a way to skip this check. This check is part of source code src/third_party/tcmalloc/dist/tcmalloc/internal/sysinfo.cc, so that would mean modifying the the source code and rebuilding mongod from modified source code.
Looks like you can turn off per-CPU caches in new TCMalloc. You can set a MALLOC_CONF before calling Mongo server:
export MALLOC_CONF=“percpu_arena:disabled”
This will bypass the num CPUs call.
Setting MALLOC_CONF
does not help.