ClickHouse/tests/queries/0_stateless/01572_kill_window_function.sh

37 lines
1.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
set -e -o pipefail
2021-08-09 18:35:34 +00:00
# Run a test query that takes very long to run.
2021-08-09 20:56:44 +00:00
query_id="01572_kill_window_function-$CLICKHOUSE_DATABASE"
$CLICKHOUSE_CLIENT --query_id="$query_id" --query "SELECT count(1048575) OVER (PARTITION BY intDiv(NULL, number) ORDER BY number DESC NULLS FIRST ROWS BETWEEN CURRENT ROW AND 1048575 FOLLOWING) FROM numbers(255, 1048575)" >/dev/null 2>&1 &
client_pid=$!
2021-08-09 19:19:54 +00:00
echo Started
2021-08-09 18:35:34 +00:00
2021-08-09 19:19:54 +00:00
# Use one query to both kill the test query and verify that it has started,
# because if we try to kill it before it starts, the test will fail.
while [ -z "$($CLICKHOUSE_CLIENT --query "kill query where query_id = '$query_id' and current_database = currentDatabase()")" ]
2021-08-09 18:35:34 +00:00
do
2021-08-09 19:19:54 +00:00
# If we don't yet see the query in the process list, the client should still
# be running. The query is very long.
kill -0 -- $client_pid
2021-08-09 18:35:34 +00:00
sleep 1
done
2021-08-09 19:19:54 +00:00
echo Sent kill request
2021-08-09 18:35:34 +00:00
# Wait for the client to terminate.
client_exit_code=0
wait $client_pid || client_exit_code=$?
2021-08-09 19:19:54 +00:00
echo "Exit $client_exit_code"
# We have tested for Ctrl+C.
# The following client flags don't cancel, but should: --max_execution_time,
# --receive_timeout. Probably needs asynchonous calculation of query limits, as
# discussed with Nikolay on TG: https://t.me/c/1214350934/21492