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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.3 KiB
Bash
Raw Normal View History

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