v.24.2Improvement

ClickHouse Updates Memory Limit Handling for Cgroups v2

At startup and whenever config files are changed, ClickHouse updates the hard memory limits of its total memory tracker. These limits are computed based on various server settings and cgroups limits (on Linux). Previously, setting /sys/fs/cgroup/memory.max (for cgroups v2) was hard-coded. As a result, cgroup v2 memory limits configured for nested groups (hierarchies), e.g. /sys/fs/cgroup/my/nested/group/memory.max were ignored. This is now fixed. The behavior of v1 memory limits remains unchanged. #59435 (Robert Schulze).
ClickHouse now correctly respects memory limits set in nested cgroups v2 hierarchies when updating its total memory tracker limits at startup and on config changes.

Why it matters

Previously, ClickHouse only considered the memory limit at the root cgroup v2 path /sys/fs/cgroup/memory.max, ignoring any limits configured in nested cgroup v2 directories. This update ensures that memory limits configured for nested cgroups (e.g., /sys/fs/cgroup/my/nested/group/memory.max) are properly detected and applied. This improves resource limit accuracy and control in containerized or hierarchical environments on Linux.

How to use it

No user configuration changes are required. ClickHouse automatically updates and applies memory limits from the correct nested cgroup v2 path at startup and whenever configuration files are reloaded.