This commit is contained in:
Dmitry Novik 2022-02-10 01:01:14 +00:00
parent b680096f87
commit d2e1f66c57
4 changed files with 18 additions and 11 deletions

View File

@ -921,9 +921,12 @@ if (ThreadFuzzer::instance().isEffective())
total_memory_tracker.setDescription("(total)");
total_memory_tracker.setMetric(CurrentMetrics::MemoryTracking);
UInt64 max_overcommit_wait_time = config->getUInt64("memory_usage_overcommit_max_wait_microseconds", 0);
auto * global_overcommit_tracker = global_context->getGlobalOvercommitTracker();
global_overcommit_tracker->setMaxWaitTime(max_overcommit_wait_time);
if (config->has("global_memory_usage_overcommit_max_wait_microseconds"))
{
UInt64 max_overcommit_wait_time = config->getUInt64("global_memory_usage_overcommit_max_wait_microseconds", 0);
global_overcommit_tracker->setMaxWaitTime(max_overcommit_wait_time);
}
total_memory_tracker.setOvercommitTracker(global_overcommit_tracker);
// FIXME logging-related things need synchronization -- see the 'Logger * log' saved

View File

@ -1,3 +0,0 @@
<clickhouse>
<max_server_memory_usage>5000000</max_server_memory_usage>
</clickhouse>

View File

@ -0,0 +1,4 @@
<clickhouse>
<max_server_memory_usage>50000000</max_server_memory_usage>
<global_memory_usage_overcommit_max_wait_microseconds>500</global_memory_usage_overcommit_max_wait_microseconds>
</clickhouse>

View File

@ -4,7 +4,7 @@ from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance('node', main_configs=['configs/config.xml'])
node = cluster.add_instance('node', main_configs=['configs/global_overcommit_tracker.xml'])
@pytest.fixture(scope='module', autouse=True)
def start_cluster():
@ -14,8 +14,8 @@ def start_cluster():
finally:
cluster.shutdown()
TEST_QUERY_A = 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS max_guaranteed_memory_usage_for_user=1,memory_usage_overcommit_max_wait_microseconds=500'
TEST_QUERY_B = 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS max_guaranteed_memory_usage_for_user=2,memory_usage_overcommit_max_wait_microseconds=500'
TEST_QUERY_A = 'SELECT number FROM numbers(10000) GROUP BY number SETTINGS max_guaranteed_memory_usage_for_user=1'
TEST_QUERY_B = 'SELECT number FROM numbers(10000) GROUP BY number SETTINGS max_guaranteed_memory_usage_for_user=2'
def test_overcommited_is_killed():
node.query("CREATE USER A")
@ -31,13 +31,16 @@ def test_overcommited_is_killed():
overcommited_killed = False
for response in responses_A:
err = response.get_error()
_, err = response.get_answer_and_error()
if "MEMORY_LIMIT_EXCEEDED" in err:
overcommited_killed = True
finished = False
for response in responses_B:
response.get_answer_and_error()
_, err = response.get_answer_and_error()
if err == "":
finished = True
assert overcommited_killed, "no overcommited task was killed"
assert overcommited_killed and finished, "no overcommited task was killed or all tasks are killed"
node.query("DROP USER IF EXISTS A")
node.query("DROP USER IF EXISTS B")