cockroachdb / cockroachdb/cockroach
cgroups.go picking up memory.pressure mountpoint
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
Since this [commit](https://github.com/systemd/systemd/commit/d4b6ec980ddd15c9d1a38fd2c5d061c249427f4f) was applied, systemd creates a cgroup2 mount for `memory.pressure`.
```
$ pid=$(sudo systemctl show --property MainPID cockroachdb | cut -d'=' -f2)
$ sudo cat /proc/$pid/mountinfo | grep cgroup2 | cut -d' ' -f5
/sys/fs/cgroup
/sys/fs/cgroup/production.slice/production-storage.slice/cockroachdb.service/memory.pressure
```
With `ProtectControlGroups=yes` option set, `/pkg/util/cgroups/cgroups.go/` ends up detecting the `memory.pressure` path. This is causes a noisy log showing this message:
```
"message": "unable to get CPU capacity: error when read cpu quota from cgroup v2 at ‹/sys/fs/cgroup/production.slice/production-storage.slice/cockroachdb.service/memory.pressure/production.slice/production-storage.slice/cockroachdb.service/cpu.max›: open ‹/sys/fs/cgroup/production.slice/production-storage.slice/cockroachdb.service/memory.pressure/production.slice/production-storage.slice/cockroachdb.service/cpu.max›: not a directory"
```
where `maxFilePath` in `detectCPUQuotaInV2()` is a join of strings of:
- `getCgroupDetails()` returns "/sys/fs/cgroup/production.slice/production-storage.slice/cockroachdb.service/memory.pressure"
- `detectCntrlPath()` returns "/production.slice/production-storage.slice/cockroachdb.service"
- `cgroupV2CPUMaxFilename` = "cpu.max"
**To Reproduce**
[This](https://github.com/cockroachdb/cockroach/blob/0363e0e81c6a36b6b659dba79656b86abe35b91e/pkg/util/cgroups/cgroups.go#L537-L540) `continue` might be how `/pkg/util/cgroups/cgroups.go/` picks other cgroup2 mounts, where it used to be a `return`.
**Expected behavior**
`maxFilePath` should be `/sys/fs/cgroup/production.slice/production-storage.slice/cockroachdb.service/cpu.max`
**Environment:**
- CockroachDB v22.2.13
- Server OS: Debian GNU/Linux 12 (bookworm)
Jira issue: CRDB-32361
Contributor guide
Assessment
This issue has not been assessed yet.