Add test race_condition_storage.sh

This commit is contained in:
vdimir 2021-02-23 19:27:44 +03:00
parent 6cc2fb5e9f
commit e4fdbbfab6
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
unset CLICKHOUSE_LOG_COMMENT
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
set -o errexit
set -o pipefail
echo "
DROP TABLE IF EXISTS storage_join_race;
CREATE TABLE storage_join_race (x UInt64, y UInt64) Engine = Join(ALL, FULL, x);
" | $CLICKHOUSE_CLIENT -n
function read_thread_big()
{
while true; do
echo "
SELECT * FROM ( SELECT number AS x FROM numbers(100000) ) AS t1 ALL FULL JOIN storage_join_race USING (x) FORMAT Null;
" | $CLICKHOUSE_CLIENT -n
done
}
function read_thread_small()
{
while true; do
echo "
SELECT * FROM ( SELECT number AS x FROM numbers(10) ) AS t1 ALL FULL JOIN storage_join_race USING (x) FORMAT Null;
" | $CLICKHOUSE_CLIENT -n
done
}
# https://stackoverflow.com/questions/9954794/execute-a-shell-function-with-timeout
export -f read_thread_big;
export -f read_thread_small;
TIMEOUT=20
timeout $TIMEOUT bash -c read_thread_big 2> /dev/null &
timeout $TIMEOUT bash -c read_thread_small 2> /dev/null &
echo "
INSERT INTO storage_join_race SELECT number AS x, number AS y FROM numbers (10000000);
" | $CLICKHOUSE_CLIENT -n
wait
$CLICKHOUSE_CLIENT -q "DROP TABLE storage_join_race"