v.22.8Improvement

Fix Memory Accounting for "Memory Limit Exceeded" Errors

Fix memory accounting in case of "Memory limit exceeded" errors (previously [peak] memory usage was takes failed allocations into account). #40249 (Azat Khuzhin).
Fix memory accounting for "Memory limit exceeded" errors by excluding failed allocations from peak memory usage calculations.

Why it matters

Previously, peak memory usage included failed allocation attempts, causing inaccurate memory accounting and possibly misleading memory limit errors. This fix ensures that only successful memory allocations contribute to peak memory usage, improving error accuracy and resource tracking.

How to use it

This fix is applied internally in memory tracking and does not require any user action. Memory limit error reporting will automatically reflect the improved accounting after upgrading to the fixed ClickHouse version.