[DOCS-15043] [Server] Investigate changes in SERVER-60412: Host memory limit check does not honor cgroups v2 Created: 18/Jan/22  Updated: 07/Feb/24  Resolved: 07/Feb/24

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 5.3.0, 4.4.14, 4.2.20, 5.0.7

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Kenneth Dyer
Resolution: Done Votes: 0
Labels: backlog, request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
backported by DOCS-15152 [BACKPORT] [v4.4] Host memory limit c... Closed
Depends
is depended on by DOCS-15153 [BACKPORT] [v5.0] Host memory limit c... Backlog
Documented
documents SERVER-60412 Host memory limit check does not hono... Closed
Duplicate
duplicates DOCS-15155 [BACKPORT] [v4.2] Host memory limit c... Closed
Participants:
Days since reply: 8 hours, 25 minutes ago
Epic Link: DOCSP-19447

 Description   
Downstream Change Summary

Adds support for using cgroups v2 to specify the memory available to the environment running a mongo server (e.g., mongod). SERVER-16571 added support for cgroups v1, and this ticket extends that support for cgroups v2.

Description of Linked Ticket

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.

 



 Comments   
Comment by Kenneth Dyer [ 07/Feb/24 ]

No changes required.

Comment by Amirsaman Memaripour [ 07/Feb/24 ]

kenneth.dyer@mongodb.com, that sounds good to me. We only added support to cgroupsv2, so if there's no need to mention that, what we currently have is correct.

Comment by Jess Mokrzecki [ 07/Mar/22 ]

Fix Version updated for upstream SERVER-60412:
5.3.0, 5.0.7, 4.4.14, 4.2.20

Comment by Jess Mokrzecki [ 07/Mar/22 ]

Fix Version updated for upstream SERVER-60412:
5.3.0, 5.0.7, 4.4.14

Comment by Jess Mokrzecki [ 07/Mar/22 ]

Fix Version updated for upstream SERVER-60412:
5.3.0, 4.4.14

Comment by PM Bot [ 18/Jan/22 ]

Downstream changes updated for upstream SERVER-60412:
Adds support for using cgroups v2 to specify the memory available to the environment running a mongo server (e.g., mongod). SERVER-16571 added support for cgroups v1, and this ticket extends that support for cgroups v2.

Generated at Thu Feb 08 08:11:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.