2020-03-30 19:15:18 +00:00
#!/usr/bin/env bash
2024-08-01 14:57:41 +00:00
# Tags: no-fasttest, no-parallel
# no-parallel: FIXME: Timing issues with INSERT + DETACH (https://github.com/ClickHouse/ClickHouse/pull/67610/files#r1700345054)
2020-03-30 19:15:18 +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
2020-03-30 19:15:18 +00:00
2024-08-01 13:17:00 +00:00
NEW_DATABASE = test_01107_${ CLICKHOUSE_DATABASE }
$CLICKHOUSE_CLIENT -q " DROP DATABASE IF EXISTS ${ NEW_DATABASE } "
$CLICKHOUSE_CLIENT -q " CREATE DATABASE ${ NEW_DATABASE } ENGINE=Atomic "
$CLICKHOUSE_CLIENT -q " CREATE TABLE ${ NEW_DATABASE } .mt (n UInt64) ENGINE=MergeTree() ORDER BY tuple() "
2020-03-30 19:15:18 +00:00
2024-08-01 13:17:00 +00:00
$CLICKHOUSE_CLIENT --function_sleep_max_microseconds_per_block 60000000 -q " INSERT INTO ${ NEW_DATABASE } .mt SELECT number + sleepEachRow(3) FROM numbers(5) " &
2020-03-30 19:15:18 +00:00
sleep 1
2024-08-01 13:17:00 +00:00
$CLICKHOUSE_CLIENT -q " DETACH TABLE ${ NEW_DATABASE } .mt " --database_atomic_wait_for_drop_and_detach_synchronously= 0
$CLICKHOUSE_CLIENT -q " ATTACH TABLE ${ NEW_DATABASE } .mt " --database_atomic_wait_for_drop_and_detach_synchronously= 0 2>& 1 | grep -F "Code: 57" > /dev/null && echo "OK"
$CLICKHOUSE_CLIENT -q " DETACH DATABASE ${ NEW_DATABASE } " --database_atomic_wait_for_drop_and_detach_synchronously= 0 2>& 1 | grep -F "Code: 219" > /dev/null && echo "OK"
2020-03-30 19:15:18 +00:00
2020-04-10 23:02:15 +00:00
wait
2024-08-01 13:17:00 +00:00
$CLICKHOUSE_CLIENT -q " ATTACH TABLE ${ NEW_DATABASE } .mt "
$CLICKHOUSE_CLIENT -q " SELECT count(n), sum(n) FROM ${ NEW_DATABASE } .mt "
$CLICKHOUSE_CLIENT -q " DETACH DATABASE ${ NEW_DATABASE } " --database_atomic_wait_for_drop_and_detach_synchronously= 0
$CLICKHOUSE_CLIENT -q " ATTACH DATABASE ${ NEW_DATABASE } "
$CLICKHOUSE_CLIENT -q " SELECT count(n), sum(n) FROM ${ NEW_DATABASE } .mt "
2020-03-30 19:15:18 +00:00
2024-08-01 13:17:00 +00:00
$CLICKHOUSE_CLIENT --function_sleep_max_microseconds_per_block 60000000 -q " INSERT INTO ${ NEW_DATABASE } .mt SELECT number + sleepEachRow(1) FROM numbers(5) " && echo "end" &
2020-04-11 15:38:41 +00:00
sleep 1
2024-08-01 13:17:00 +00:00
$CLICKHOUSE_CLIENT -q " DROP DATABASE ${ NEW_DATABASE } " --database_atomic_wait_for_drop_and_detach_synchronously= 0 && sleep 1 && echo "dropped"
2020-05-17 01:15:59 +00:00
wait