ClickHouse/tests/queries/0_stateless/01003_kill_query_race_condition.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

2019-08-30 23:19:05 +00:00
#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: race
2019-08-30 23:19:05 +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-30 23:19:05 +00:00
set -e
function thread1()
{
while true; do
2019-08-31 01:21:10 +00:00
$CLICKHOUSE_CLIENT --query_id=hello --query "SELECT count() FROM numbers(1000000000)" --format Null;
2019-08-30 23:19:05 +00:00
done
}
function thread2()
{
while true; do
$CLICKHOUSE_CLIENT --query "KILL QUERY WHERE query_id = 'hello'" --format Null;
sleep 0.$RANDOM
done
}
function thread3()
{
while true; do
$CLICKHOUSE_CLIENT --query "SHOW PROCESSLIST" --format Null;
$CLICKHOUSE_CLIENT --query "SELECT * FROM system.processes" --format Null;
done
}
# https://stackoverflow.com/questions/9954794/execute-a-shell-function-with-timeout
export -f thread1;
export -f thread2;
export -f thread3;
TIMEOUT=10
timeout $TIMEOUT bash -c thread1 2> /dev/null &
timeout $TIMEOUT bash -c thread1 2> /dev/null &
timeout $TIMEOUT bash -c thread1 2> /dev/null &
timeout $TIMEOUT bash -c thread1 2> /dev/null &
timeout $TIMEOUT bash -c thread2 2> /dev/null &
timeout $TIMEOUT bash -c thread3 2> /dev/null &
timeout $TIMEOUT bash -c thread3 2> /dev/null &
timeout $TIMEOUT bash -c thread3 2> /dev/null &
timeout $TIMEOUT bash -c thread3 2> /dev/null &
wait