v.20.4Improvement

Added max_server_memory_usage Setting and Deprecated max_memory_usage_for_all_queries

Added a setting max_server_memory_usage to limit total memory usage of the server. The metric MemoryTracking is now calculated without a drift. The setting max_memory_usage_for_all_queries is now obsolete and does nothing. This closes #10293. #10362 (alexey-milovidov)
Introduced a new server setting max_server_memory_usage to limit the total memory usage of the ClickHouse server, replacing the obsolete max_memory_usage_for_all_queries setting. Additionally, improved accuracy of the MemoryTracking metric by eliminating its drift.

Why it matters

This feature addresses the challenge of managing overall server memory consumption by providing a centralized memory usage limit. It enhances stability and resource control, preventing excessive memory usage that could degrade performance or cause failures. Accurate MemoryTracking metrics enable better monitoring and debugging of memory usage.

How to use it

To enable this feature, set the max_server_memory_usage configuration option in the server settings to the desired memory limit value. The previous setting max_memory_usage_for_all_queries is now ignored and should be removed from configuration. Memory usage tracking improvements are applied automatically.