ClickHouse/tests/queries/0_stateless/01602_max_distributed_connections.sh
Azat Khuzhin d28963d695 tests: do not leave any queries after finish
This should fix issues like [1], where because one query from the
previous test was left the next fails, in this particular report the
problem was that 01281_group_by_limit_memory_tracking fails due to the
query from 01301_aggregate_state_exception_memory_leak was running in
background.

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/34919/311f884d3d4215f7f82c2dd66ea51d071d313241/stateless_tests__thread__actions__[2/3].html

v2: wait for queries in 01249_flush_interactive
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-03-09 17:29:33 +03:00

43 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tags: distributed
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# We check that even if max_threads is small, the setting max_distributed_connections
# will allow to process queries on multiple shards concurrently.
# 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
# and the following loops will finish with probability 1 assuming independent random variables.
i=0 retries=30
while [[ $i -lt $retries ]]; do
clickhouse_client_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
((++i))
done
i=0 retries=30
while [[ $i -lt $retries ]]; do
clickhouse_client_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
((++i))
done
# If max_distributed_connections is low and async_socket_for_remote is disabled,
# the concurrency of distributed queries will be also low.
clickhouse_client_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'
clickhouse_client_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'
# FIXME
clickhouse_test_wait_queries 5
echo 'Ok'