2020-12-06 22:12:54 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: distributed
|
2020-12-06 22:12:54 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-12-06 22:12:54 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
2021-04-19 19:36:45 +00:00
|
|
|
# We check that even if max_threads is small, the setting max_distributed_connections
|
|
|
|
# will allow to process queries on multiple shards concurrently.
|
2020-12-06 22:12:54 +00:00
|
|
|
|
2021-04-20 00:20:36 +00:00
|
|
|
# We do sleep 1.5 seconds on ten machines.
|
|
|
|
# If concurrency is one (bad) the query will take at least 15 seconds and the following loops are guaranteed to be infinite.
|
|
|
|
# If concurrency is 10 (good), the query may take less than 10 second with non-zero probability
|
2021-04-19 19:36:45 +00:00
|
|
|
# and the following loops will finish with probability 1 assuming independent random variables.
|
2020-12-06 22:12:54 +00:00
|
|
|
|
2021-10-11 13:40:12 +00:00
|
|
|
i=0 retries=30
|
|
|
|
while [[ $i -lt $retries ]]; do
|
2021-04-20 00:20:36 +00:00
|
|
|
timeout 10 ${CLICKHOUSE_CLIENT} --max_threads 1 --max_distributed_connections 10 --query "
|
|
|
|
SELECT sleep(1.5) FROM remote('127.{1..10}', system.one) FORMAT Null" --prefer_localhost_replica=0 && break
|
2021-10-11 13:40:12 +00:00
|
|
|
((++i))
|
2021-04-19 19:36:45 +00:00
|
|
|
done
|
|
|
|
|
2021-10-11 13:40:12 +00:00
|
|
|
i=0 retries=30
|
|
|
|
while [[ $i -lt $retries ]]; do
|
2021-04-20 00:20:36 +00:00
|
|
|
timeout 10 ${CLICKHOUSE_CLIENT} --max_threads 1 --max_distributed_connections 10 --query "
|
|
|
|
SELECT sleep(1.5) FROM remote('127.{1..10}', system.one) FORMAT Null" --prefer_localhost_replica=1 && break
|
2021-10-11 13:40:12 +00:00
|
|
|
((++i))
|
2021-04-19 19:36:45 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# If max_distributed_connections is low and async_socket_for_remote is disabled,
|
|
|
|
# the concurrency of distributed queries will be also low.
|
|
|
|
|
|
|
|
timeout 1 ${CLICKHOUSE_CLIENT} --max_threads 1 --max_distributed_connections 1 --async_socket_for_remote 0 --query "
|
|
|
|
SELECT sleep(0.15) FROM remote('127.{1..10}', system.one) FORMAT Null" --prefer_localhost_replica=0 && echo 'Fail'
|
|
|
|
|
|
|
|
timeout 1 ${CLICKHOUSE_CLIENT} --max_threads 1 --max_distributed_connections 1 --async_socket_for_remote 0 --query "
|
|
|
|
SELECT sleep(0.15) FROM remote('127.{1..10}', system.one) FORMAT Null" --prefer_localhost_replica=1 && echo 'Fail'
|
2021-04-19 19:42:39 +00:00
|
|
|
|
|
|
|
echo 'Ok'
|