Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-60412

Host memory limit check does not honor cgroups v2

    • Fully Compatible
    • ALL
    • v5.0, v4.4, v4.2
    • Service Arch 2022-1-24
    • 2

      As I checked mongoDB gained support for memory constraints over cgroup in linux with SERVER-16571. However it seems that it doesn't have the ability to check memory limit if host is using cgroups v2 resulting hostInfo.system.memLimitMB to be equal to system memory in a containerized environment.

      Current code to read memory limits in src/mongo/util/processinfo_linux.cpp

      // LinuxSysHelper::getMemorySizeLimit().
      std::string cgmemlimit = readLineFromFile("/sys/fs/cgroup/memory/memory.limit_in_bytes");

      But in cgroups v2 the memory limit is at /sys/fs/cgroup/memory.max.

      I think engine should check if the cgroups v2 is enabled on the host and then read the limits according to that.

      Tested on mongodb 4.2.6 in docker containers at host Fedore CoreOS 34.20210904.3.0. But I do believe newer versions have the same since source code seems same since first implementation.


            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            ayhanap@gmail.com Ayhan APAYDIN
            2 Vote for this issue
            16 Start watching this issue