ClickHouse/tests/integration/test_fetch_memory_usage/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.9 KiB
Python
Raw Normal View History

2022-08-08 13:32:49 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance(
"node", main_configs=["configs/config.xml"], with_zookeeper=True
)
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_huge_column(started_cluster):
2022-08-09 12:25:58 +00:00
if (
node.is_built_with_thread_sanitizer()
or node.is_built_with_memory_sanitizer()
or node.is_built_with_address_sanitizer()
):
pytest.skip("sanitizer build has higher memory consumption; also it is slow")
2022-08-08 13:32:49 +00:00
# max_server_memory_usage is set to 1GB
# Added column should be 1e6 * 2000 ~= 2GB
# ALTER ADD COLUMN + MATRIALIZE COLUMN should not cause big memory consumption
2022-08-08 13:46:38 +00:00
node.query(
"""
2022-08-08 13:32:49 +00:00
create table test_fetch (x UInt64) engine = ReplicatedMergeTree('/clickhouse/tables/test_fetch', 'r1') order by x settings index_granularity=1024;
insert into test_fetch select number from numbers(1e6);
set mutations_sync=1;
alter table test_fetch add column y String default repeat(' ', 2000) CODEC(NONE);
alter table test_fetch materialize column y;
create table test_fetch2 (x UInt64, y String default repeat(' ', 2000) CODEC(NONE)) engine = ReplicatedMergeTree('/clickhouse/tables/test_fetch', 'r2') order by x settings index_granularity=1024;
2022-08-08 13:46:38 +00:00
"""
)
2022-08-08 13:32:49 +00:00
# Here we just check that fetch has started.
2022-08-08 13:46:38 +00:00
node.query(
"""
2022-08-08 13:32:49 +00:00
set receive_timeout=1;
system sync replica test_fetch2;
2022-08-08 13:46:38 +00:00
""",
ignore_error=True,
)
2022-08-08 13:32:49 +00:00
# Here we check that fetch did not use too much memory.
# See https://github.com/ClickHouse/ClickHouse/issues/39915
2022-08-08 13:46:38 +00:00
maybe_exception = node.query(
"select last_exception from system.replication_queue where last_exception like '%Memory limit%';"
)
2022-08-08 13:32:49 +00:00
assert maybe_exception == ""