ClickHouse/tests/queries/0_stateless/01164_detach_attach_partition_race.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

2021-11-24 19:45:10 +00:00
#!/usr/bin/env bash
# Tags: race
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -q "create table mt (n int) engine=MergeTree order by n"
$CLICKHOUSE_CLIENT -q "insert into mt values (1)"
$CLICKHOUSE_CLIENT -q "insert into mt values (2)"
$CLICKHOUSE_CLIENT -q "insert into mt values (3)"
function thread_insert()
{
$CLICKHOUSE_CLIENT -q "insert into mt values (rand())";
2021-11-24 19:45:10 +00:00
}
function thread_detach_attach()
{
$CLICKHOUSE_CLIENT -q "alter table mt detach partition id 'all'";
$CLICKHOUSE_CLIENT -q "alter table mt attach partition id 'all'";
2021-11-24 19:45:10 +00:00
}
function thread_drop_detached()
{
$CLICKHOUSE_CLIENT --allow_drop_detached -q "alter table mt drop detached partition id 'all'";
2021-11-24 19:45:10 +00:00
}
export -f thread_insert
export -f thread_detach_attach
export -f thread_drop_detached
2021-11-24 19:45:10 +00:00
TIMEOUT=10
clickhouse_client_loop_timeout $TIMEOUT thread_insert &
clickhouse_client_loop_timeout $TIMEOUT thread_detach_attach 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT thread_detach_attach 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT thread_drop_detached 2> /dev/null &
2021-11-24 19:45:10 +00:00
wait
$CLICKHOUSE_CLIENT -q "drop table mt"