2020-09-19 12:15:47 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: deadlock
|
2020-09-19 12:15:47 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=fatal
|
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-09-19 12:15:47 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_create()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "CREATE TABLE IF NOT EXISTS $1 (x UInt64, s Array(Nullable(String))) ENGINE = $2"
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_drop()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS $1"
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_rename()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "RENAME TABLE $1 TO $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|57)'
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_select()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM $1 FORMAT Null" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)'
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_insert()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT rand64(1), [toString(rand64(2))] FROM numbers($2)" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: '| grep -v -P 'Code: (60|218)'
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
function thread_insert_select()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT * FROM $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)'
|
|
|
|
sleep 0.0$RANDOM
|
2020-09-19 12:15:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export -f thread_create
|
|
|
|
export -f thread_drop
|
|
|
|
export -f thread_rename
|
|
|
|
export -f thread_select
|
|
|
|
export -f thread_insert
|
|
|
|
export -f thread_insert_select
|
|
|
|
|
|
|
|
|
|
|
|
# Do randomized queries and expect nothing extraordinary happens.
|
|
|
|
|
|
|
|
function test_with_engine {
|
|
|
|
echo "Testing $1"
|
|
|
|
|
2022-04-06 06:24:04 +00:00
|
|
|
clickhouse_client_loop_timeout 10 thread_create t1 $1 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_create t2 $1 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_drop t1 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_drop t2 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_rename t1 t2 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_rename t2 t1 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_select t1 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_select t2 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_insert t1 5 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_insert t2 10 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_insert_select t1 t2 &
|
|
|
|
clickhouse_client_loop_timeout 10 thread_insert_select t2 t1 &
|
2020-09-19 12:15:47 +00:00
|
|
|
|
|
|
|
wait
|
|
|
|
echo "Done $1"
|
|
|
|
}
|
|
|
|
|
2020-10-13 13:31:02 +00:00
|
|
|
#test_with_engine TinyLog
|
|
|
|
#test_with_engine StripeLog
|
|
|
|
#test_with_engine Log
|
|
|
|
test_with_engine Memory
|
2020-12-04 02:15:44 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t1"
|
|
|
|
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t2"
|