2023-04-14 14:34:19 +00:00
import pytest
from helpers . cluster import ClickHouseCluster
cluster = ClickHouseCluster ( __file__ )
node = cluster . add_instance ( " node " )
@pytest.fixture ( scope = " module " , autouse = True )
def start_cluster ( ) :
try :
cluster . start ( )
yield cluster
finally :
cluster . shutdown ( )
def test_memory_limit_success ( ) :
node . query (
" CREATE TABLE test_merge_oom ENGINE=AggregatingMergeTree ORDER BY id EMPTY AS SELECT number % 1024 AS id, arrayReduce( ' groupArrayState ' , arrayMap( x-> randomPrintableASCII(100), range(8192))) fat_state FROM numbers(20000) "
)
node . query ( " SYSTEM STOP MERGES test_merge_oom " )
node . query (
2023-05-02 23:33:26 +00:00
" INSERT INTO test_merge_oom SELECT number % 1024 AS id, arrayReduce( ' groupArrayState ' , arrayMap( x-> randomPrintableASCII(100), range(8192))) fat_state FROM numbers(3000) "
2023-04-14 14:34:19 +00:00
)
node . query (
2023-05-02 23:33:26 +00:00
" INSERT INTO test_merge_oom SELECT number % 1024 AS id, arrayReduce( ' groupArrayState ' , arrayMap( x-> randomPrintableASCII(100), range(8192))) fat_state FROM numbers(3000) "
2023-04-14 14:34:19 +00:00
)
2023-05-02 23:33:26 +00:00
node . query (
" INSERT INTO test_merge_oom SELECT number % 1024 AS id, arrayReduce( ' groupArrayState ' , arrayMap( x-> randomPrintableASCII(100), range(8192))) fat_state FROM numbers(3000) "
)
2023-04-14 14:34:19 +00:00
_ , error = node . query_and_get_answer_with_error (
" SYSTEM START MERGES test_merge_oom;SET optimize_throw_if_noop=1;OPTIMIZE TABLE test_merge_oom FINAL "
)
assert not error
node . query ( " DROP TABLE test_merge_oom " )