ClickHouse/tests/queries/0_stateless/01412_cache_dictionary_race.sh

70 lines
2.1 KiB
Bash
Raw Normal View History

2020-07-17 15:18:52 +00:00
#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: race, no-parallel
2020-07-17 15:18:52 +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-07-17 15:18:52 +00:00
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS ordinary_db"
$CLICKHOUSE_CLIENT --query "CREATE DATABASE ordinary_db"
$CLICKHOUSE_CLIENT -n -q "
CREATE DICTIONARY ordinary_db.dict1
(
key_column UInt64 DEFAULT 0,
second_column UInt8 DEFAULT 1,
third_column String DEFAULT 'qqq'
)
PRIMARY KEY key_column
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'view_for_dict' PASSWORD '' DB 'ordinary_db'))
2020-07-17 15:18:52 +00:00
LIFETIME(MIN 1 MAX 3)
LAYOUT(CACHE(SIZE_IN_CELLS 3));
"
function dict_get_thread()
{
$CLICKHOUSE_CLIENT --query "SELECT dictGetString('ordinary_db.dict1', 'third_column', toUInt64(rand() % 1000)) from numbers(2)" &>/dev/null
2020-07-17 15:18:52 +00:00
}
function drop_create_table_thread()
{
$CLICKHOUSE_CLIENT -n --query "CREATE TABLE ordinary_db.table_for_dict_real (
key_column UInt64,
second_column UInt8,
third_column String
)
ENGINE MergeTree() ORDER BY tuple();
INSERT INTO ordinary_db.table_for_dict_real SELECT number, number, toString(number) from numbers(2);
CREATE VIEW ordinary_db.view_for_dict AS SELECT key_column, second_column, third_column from ordinary_db.table_for_dict_real WHERE sleepEachRow(1) == 0;
2020-07-17 15:18:52 +00:00
"
sleep 10
2020-07-17 15:18:52 +00:00
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS ordinary_db.table_for_dict_real"
sleep 10
2020-07-17 15:18:52 +00:00
}
export -f dict_get_thread
export -f drop_create_table_thread
2020-07-17 15:18:52 +00:00
TIMEOUT=30
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
clickhouse_client_loop_timeout $TIMEOUT bash -c dict_get_thread 2> /dev/null &
2020-07-17 15:18:52 +00:00
clickhouse_client_loop_timeout $TIMEOUT bash -c drop_create_table_thread 2> /dev/null &
2020-07-17 15:18:52 +00:00
wait
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS ordinary_db"