ClickHouse/tests/queries/0_stateless/01019_parallel_parsing_cancel.sh
Azat Khuzhin 155fe2bf9b Fix stress hung because of attached MV with sleep()
In stress tests non-unique databases are used, and in case of non-unique
table names, materialized views may affect other tests, especially if
SELECT from underlying table contains sleep*() like in
02187_insert_values_with_mv, CI report [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/37469/2b513acb2b8d703e737a700a9ccd5f7f323b605f/stress_test__undefined__actions_.html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-06-07 07:52:06 +03:00

52 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS data_a_01019;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS data_b_01019;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE data_a_01019 (x UInt64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE data_b_01019 (x UInt64) ENGINE = Memory;"
function thread1()
{
for _ in {1..10}
do
seq 1 500000 | $CLICKHOUSE_CLIENT --query_id=11 --query="INSERT INTO data_a_01019 FORMAT TSV" &
while true; do
$CLICKHOUSE_CLIENT --query="KILL QUERY WHERE query_id='11' SYNC" | grep -q "cant_cancel" && sleep .1 || break ||:
done
while true; do
$CLICKHOUSE_CLIENT --query="SELECT count(*)>0 FROM system.processes WHERE query_id='11'" | grep -q "1" && sleep .1 || break ||:
done
done
}
function thread2()
{
for _ in {1..10}
do
seq 1 500000 | $CLICKHOUSE_CLIENT --query_id=22 --query="INSERT INTO data_b_01019 FORMAT TSV" &
while true; do
$CLICKHOUSE_CLIENT --query="KILL QUERY WHERE query_id='22' SYNC" | grep -q "cant_cancel" && sleep .1 || break ||:
done
while true; do
$CLICKHOUSE_CLIENT --query="SELECT count(*)>0 FROM system.processes WHERE query_id='22'" | grep -q "1" && sleep .1 || break ||:
done
done
}
export -f thread1;
export -f thread2;
bash -c thread1 > /dev/null 2>&1 &
bash -c thread2 > /dev/null 2>&1 &
wait
echo OK
$CLICKHOUSE_CLIENT --query "DROP TABLE data_a_01019"
$CLICKHOUSE_CLIENT --query "DROP TABLE data_b_01019"