Remove timeout

This commit is contained in:
Antonio Andelic 2023-07-18 19:28:35 +00:00
parent 482c8b5cde
commit e0f737f363

View File

@ -10,7 +10,8 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
function thread1()
{
thread_id=$1
while true; do
local TIMELIMIT=$((SECONDS+$2))
while [ $SECONDS -lt "$TIMELIMIT" ]; do
query_id="02497_$CLICKHOUSE_DATABASE-$RANDOM-$thread_id"
$CLICKHOUSE_CLIENT --query_id=$query_id --query "
SELECT count() FROM numbers_mt(100000) SETTINGS
@ -25,7 +26,8 @@ function thread1()
function thread2()
{
while true; do
local TIMELIMIT=$((SECONDS+$1))
while [ $SECONDS -lt "$TIMELIMIT" ]; do
$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS"
done
}
@ -35,29 +37,12 @@ export -f thread2
TIMEOUT=10
timeout $TIMEOUT bash -c "thread1 0" >/dev/null &
timeout $TIMEOUT bash -c "thread1 1" >/dev/null &
timeout $TIMEOUT bash -c "thread1 2" >/dev/null &
timeout $TIMEOUT bash -c "thread1 3" >/dev/null &
timeout $TIMEOUT bash -c thread2 >/dev/null &
thread1 0 $TIMEOUT >/dev/null &
thread1 1 $TIMEOUT >/dev/null &
thread1 2 $TIMEOUT >/dev/null &
thread1 3 $TIMEOUT >/dev/null &
thread2 $TIMEOUT >/dev/null &
wait
for _ in {1..10}
do
$CLICKHOUSE_CLIENT -q "KILL QUERY WHERE query_id LIKE '02497_$CLICKHOUSE_DATABASE%' SYNC" >/dev/null
# After this moment, the server can still run another query.
# For example, the 'timeout' command killed all threads of thread1,
# and the 'timeout' itself has finished, and we have successfully 'wait'-ed for it,
# but just before that, one of the threads successfully sent a query to the server,
# but the server didn't start to run this query yet,
# and even when the KILL QUERY was run, the query from the thread didn't start,
# but only started after the KILL QUERY has been already processed.
# That's why we have to run this in a loop.
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE query_id LIKE '02497_$CLICKHOUSE_DATABASE%'" | rg '^0$' && break
sleep 1
done
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE query_id LIKE '02497_$CLICKHOUSE_DATABASE%'" | rg '^0$'