mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
function wait_for_mutation()
|
|
{
|
|
local table=$1
|
|
local mutation_id=$2
|
|
local database=$3
|
|
database=${database:="${CLICKHOUSE_DATABASE}"}
|
|
|
|
for i in {1..100}
|
|
do
|
|
sleep 0.1
|
|
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT min(is_done) FROM system.mutations WHERE database='$database' AND table='$table' AND mutation_id='$mutation_id'") -eq 1 ]]; then
|
|
break
|
|
fi
|
|
|
|
if [[ $i -eq 100 ]]; then
|
|
echo "Timed out while waiting for mutation to execute!"
|
|
fi
|
|
|
|
done
|
|
}
|
|
|
|
function wait_for_all_mutations()
|
|
{
|
|
local table=$1
|
|
local database=$2
|
|
database=${database:="${CLICKHOUSE_DATABASE}"}
|
|
|
|
for i in {1..200}
|
|
do
|
|
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT coalesce(minOrNull(is_done), 1) FROM system.mutations WHERE database='$database' AND table like '$table'") -eq 1 ]]; then
|
|
break
|
|
fi
|
|
|
|
if [[ $i -eq 200 ]]; then
|
|
echo "Timed out while waiting for mutation to execute!"
|
|
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.mutations WHERE database='$database' AND table like '$table' AND is_done=0"
|
|
fi
|
|
|
|
sleep 0.3
|
|
done
|
|
}
|
|
|
|
# vi: ft=bash
|