ClickHouse/tests/queries/0_stateless/01443_merge_truncate_long.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
922 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: long
set -e
2023-06-25 02:11:27 +00:00
CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=none
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS t"
2023-06-25 02:11:27 +00:00
${CLICKHOUSE_CLIENT} --query="CREATE TABLE t (x Int8) ENGINE = MergeTree ORDER BY ()"
function thread_optimize()
2023-06-25 02:11:27 +00:00
{
while true;
2023-06-25 02:11:27 +00:00
do
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE t FINAL;" 2>&1 | tr -d '\n' | rg -v 'Cancelled merging parts' ||:
done
}
TIMEOUT=15
export -f thread_optimize
timeout $TIMEOUT bash -c thread_optimize 2> /dev/null &
for i in {1..100};
do
2023-06-25 02:11:27 +00:00
echo "
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (0);
TRUNCATE TABLE t;
SELECT count() FROM t HAVING count() > 0;
SELECT ${i};
"
done | ${CLICKHOUSE_CLIENT} --multiquery
wait
$CLICKHOUSE_CLIENT -q "DROP TABLE t"