2020-10-13 15:00:36 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: no-parallel
|
2020-10-13 15:00:36 +00:00
|
|
|
|
|
|
|
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-10-13 15:00:36 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS test_01150"
|
|
|
|
$CLICKHOUSE_CLIENT --query "CREATE DATABASE test_01150"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "CREATE TABLE test_01150.t1 (x UInt64, s Array(Nullable(String))) ENGINE = Memory"
|
|
|
|
$CLICKHOUSE_CLIENT --query "CREATE TABLE test_01150.t2 (x UInt64, s Array(Nullable(String))) ENGINE = Memory"
|
|
|
|
|
2022-05-28 17:20:32 +00:00
|
|
|
function thread_detach_attach {
|
|
|
|
while true; do
|
|
|
|
$CLICKHOUSE_CLIENT --query "DETACH DATABASE test_01150" 2>&1 | grep -v -F -e 'Received exception from server' -e 'Code: 219' -e '(query: '
|
|
|
|
sleep 0.0$RANDOM
|
|
|
|
$CLICKHOUSE_CLIENT --query "ATTACH DATABASE test_01150" 2>&1 | grep -v -F -e 'Received exception from server' -e 'Code: 82' -e '(query: '
|
|
|
|
sleep 0.0$RANDOM
|
|
|
|
done
|
2020-10-13 15:00:36 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 17:20:32 +00:00
|
|
|
function thread_rename {
|
|
|
|
while true; do
|
|
|
|
$CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t1 TO test_01150.t2_tmp, test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)'
|
|
|
|
sleep 0.0$RANDOM
|
|
|
|
$CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)'
|
|
|
|
sleep 0.0$RANDOM
|
|
|
|
$CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)'
|
|
|
|
sleep 0.0$RANDOM
|
|
|
|
done
|
2020-10-13 15:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export -f thread_detach_attach
|
|
|
|
export -f thread_rename
|
|
|
|
|
2022-05-28 17:20:32 +00:00
|
|
|
timeout 20 bash -c "thread_detach_attach" &
|
|
|
|
timeout 20 bash -c 'thread_rename' &
|
2020-10-13 15:00:36 +00:00
|
|
|
wait
|
|
|
|
sleep 1
|
|
|
|
|
2020-10-14 17:01:03 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "DETACH DATABASE IF EXISTS test_01150"
|
2020-10-13 15:00:36 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "ATTACH DATABASE IF NOT EXISTS test_01150"
|
2021-09-10 18:02:31 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "DROP DATABASE test_01150"
|