ClickHouse/tests/queries/0_stateless/01019_parallel_parsing_cancel.sh

52 lines
1.7 KiB
Bash
Raw Normal View History

2019-10-25 18:03:38 +00:00
#!/usr/bin/env bash
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-10-25 18:03:38 +00:00
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS a;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS b;"
2019-10-25 18:03:38 +00:00
$CLICKHOUSE_CLIENT --query="CREATE TABLE a (x UInt64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE b (x UInt64) ENGINE = Memory;"
2019-10-25 18:03:38 +00:00
function thread1()
{
2020-08-01 00:40:56 +00:00
for _ in {1..10}
2019-12-13 16:44:33 +00:00
do
seq 1 500000 | $CLICKHOUSE_CLIENT --query_id=11 --query="INSERT INTO a FORMAT TSV" &
2019-12-13 16:44:33 +00:00
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
2019-10-25 18:03:38 +00:00
done
}
function thread2()
{
2020-08-01 00:40:56 +00:00
for _ in {1..10}
2019-12-13 16:44:33 +00:00
do
seq 1 500000 | $CLICKHOUSE_CLIENT --query_id=22 --query="INSERT INTO b FORMAT TSV" &
2019-12-13 16:44:33 +00:00
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
2019-10-25 18:03:38 +00:00
done
}
export -f thread1;
export -f thread2;
2020-03-04 10:46:14 +00:00
bash -c thread1 > /dev/null 2>&1 &
bash -c thread2 > /dev/null 2>&1 &
2019-10-25 18:03:38 +00:00
wait
echo OK
$CLICKHOUSE_CLIENT --query "DROP TABLE a"
$CLICKHOUSE_CLIENT --query "DROP TABLE b"