2018-09-04 20:56:09 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
2019-08-21 21:28:05 +00:00
|
|
|
CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=none
|
|
|
|
|
2018-09-04 20:56:09 +00:00
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
. $CURDIR/../shell_config.sh
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} --multiquery --query="
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS memory;
|
|
|
|
CREATE TABLE memory (x UInt64) ENGINE = Memory;
|
2018-09-04 20:56:09 +00:00
|
|
|
|
|
|
|
SET max_block_size = 1, min_insert_block_size_rows = 0, min_insert_block_size_bytes = 0;
|
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO memory SELECT * FROM numbers(1000);"
|
2018-09-04 20:56:09 +00:00
|
|
|
|
|
|
|
|
2019-07-31 22:49:14 +00:00
|
|
|
# NOTE Most of the time this query can start before the table will be dropped.
|
|
|
|
# And TRUNCATE or DROP query will test for correct locking inside ClickHouse.
|
|
|
|
# But if the table will be dropped before query - just pass.
|
|
|
|
# It's Ok, because otherwise the test will depend on the race condition in the test itself.
|
|
|
|
|
2018-09-04 20:56:09 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --multiquery --query="
|
|
|
|
SET max_threads = 1;
|
2019-08-20 18:11:39 +00:00
|
|
|
SELECT count() FROM memory WHERE NOT ignore(sleep(0.0001));" 2>&1 | grep -c -P '^1000$|^0$|Table .+? doesn.t exist' &
|
2018-09-04 20:56:09 +00:00
|
|
|
|
|
|
|
sleep 0.05;
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} --multiquery --query="
|
2019-04-16 14:13:13 +00:00
|
|
|
TRUNCATE TABLE memory;
|
|
|
|
DROP TABLE memory;
|
2018-09-04 20:56:09 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
wait
|