2019-08-07 13:35:28 +00:00
#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: race, no-debug
2019-08-07 13:35:28 +00:00
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:51:12 +00:00
. " $CURDIR " /../shell_config.sh
2019-08-07 13:35:28 +00:00
$CLICKHOUSE_CLIENT --query= "DROP TABLE IF EXISTS table_for_concurrent_alter"
2023-02-20 22:43:11 +00:00
$CLICKHOUSE_CLIENT --query= "CREATE TABLE table_for_concurrent_alter (id UInt64, Data String) ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity=4096, index_granularity_bytes = '10Mi';" ;
2019-08-07 13:35:28 +00:00
n = 0
2019-08-29 08:02:50 +00:00
while [ " $n " -lt 50 ] ;
2019-08-07 13:35:28 +00:00
do
n = $(( n + 1 ))
$CLICKHOUSE_CLIENT --query= "INSERT INTO table_for_concurrent_alter VALUES(1, 'Hello')" > /dev/null 2> /dev/null &
$CLICKHOUSE_CLIENT --query= "OPTIMIZE TABLE table_for_concurrent_alter FINAL" > /dev/null 2> /dev/null &
done &
q = 0
2019-08-29 08:02:50 +00:00
while [ " $q " -lt 50 ] ;
2019-08-07 13:35:28 +00:00
do
q = $(( q + 1 ))
counter = $(( 100 + q ))
$CLICKHOUSE_CLIENT --query= " ALTER TABLE table_for_concurrent_alter MODIFY SETTING parts_to_throw_insert = $counter , parts_to_delay_insert = $counter , min_merge_bytes_to_use_direct_io = $counter " > /dev/null 2> /dev/null &
done &
sleep 4
2020-06-22 13:38:37 +00:00
# if we have too many simultaneous queries
until $CLICKHOUSE_CLIENT --query "SELECT 1" 2>/dev/null 1>/dev/null
do
sleep 0.5
done
2019-08-07 13:35:28 +00:00
$CLICKHOUSE_CLIENT --query "SELECT 1"
$CLICKHOUSE_CLIENT --query= "DROP TABLE IF EXISTS table_for_concurrent_alter"