mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
add test
This commit is contained in:
parent
0f0e1cee63
commit
7e0ed1b02c
@ -230,7 +230,7 @@ void CgroupsMemoryUsageObserver::setMemoryUsageLimits(uint64_t hard_limit_, uint
|
||||
# endif
|
||||
/// Reset current usage in memory tracker. Expect zero for free_memory_in_allocator_arenas as we just purged them.
|
||||
uint64_t memory_usage = cgroup_reader->readMemoryUsage();
|
||||
LOG_TRACE(log, "Read current memory usage {} from cgroups", ReadableSize(memory_usage));
|
||||
LOG_TRACE(log, "Read current memory usage {} bytes ({}) from cgroups", memory_usage, ReadableSize(memory_usage));
|
||||
MemoryTracker::setRSS(memory_usage, 0);
|
||||
|
||||
LOG_INFO(log, "Purged jemalloc arenas. Current memory usage is {}", ReadableSize(memory_usage));
|
||||
@ -302,7 +302,7 @@ void CgroupsMemoryUsageObserver::runThread()
|
||||
if (soft_limit > 0 && hard_limit > 0)
|
||||
{
|
||||
uint64_t memory_usage = cgroup_reader->readMemoryUsage();
|
||||
LOG_TRACE(log, "Read current memory usage {} from cgroups", ReadableSize(memory_usage));
|
||||
LOG_TRACE(log, "Read current memory usage {} bytes ({}) from cgroups", memory_usage, ReadableSize(memory_usage));
|
||||
if (memory_usage > hard_limit)
|
||||
{
|
||||
if (last_memory_usage <= hard_limit)
|
||||
|
@ -35,7 +35,7 @@ def get_latest_mem_limit():
|
||||
).strip()
|
||||
)
|
||||
return mem_limit
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
raise Exception("Cannot get memory limit")
|
||||
|
||||
@ -51,3 +51,26 @@ def test_observe_memory_limit(started_cluster):
|
||||
if new_max_mem > original_max_mem:
|
||||
return
|
||||
raise Exception("the memory limit does not increase as expected")
|
||||
|
||||
|
||||
def test_memory_usage_doesnt_include_page_cache_size(started_cluster):
|
||||
# populate page cache with 10GB of data
|
||||
node1.exec_in_container(
|
||||
["dd", "if=/dev/zero", "of=outputfile", "bs=1M", "count=10K"]
|
||||
)
|
||||
|
||||
observer_refresh_period = int(
|
||||
node1.query(
|
||||
"select value from system.server_settings where name = 'cgroups_memory_usage_observer_wait_time'"
|
||||
).strip()
|
||||
)
|
||||
time.sleep(observer_refresh_period + 1)
|
||||
|
||||
max_mem_usage_from_cgroup = node1.query(
|
||||
"""
|
||||
SELECT max(toUInt64(replaceRegexpAll(message, 'Read current memory usage (\\d+) bytes.*', '\\1'))) AS max_mem
|
||||
FROM system.text_log
|
||||
WHERE logger_name = 'CgroupsMemoryUsageObserver' AND message LIKE 'Read current memory usage%bytes%'
|
||||
"""
|
||||
).strip()
|
||||
assert int(max_mem_usage_from_cgroup) < 2 * 2 ** 30
|
||||
|
Loading…
Reference in New Issue
Block a user