mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-09 16:02:23 +00:00
40 lines
1007 B
Bash
40 lines
1007 B
Bash
#!/usr/bin/env bash
|
|
|
|
function wait_for_delete_empty_parts()
|
|
{
|
|
local table=$1
|
|
local database=${2:-$CLICKHOUSE_DATABASE}
|
|
local timeout=${3:-20}
|
|
|
|
while [[ timeout -gt 0 ]]
|
|
do
|
|
res=$(${CLICKHOUSE_CLIENT} --query="SELECT count() FROM system.parts WHERE database='$database' AND table='$table' AND active AND rows=0")
|
|
[[ $res -eq 0 ]] && return 0
|
|
|
|
sleep 2
|
|
timeout=$((timeout - 2))
|
|
done
|
|
|
|
echo "Timed out while waiting for delete empty parts!" >&2
|
|
return 2
|
|
}
|
|
|
|
function wait_for_delete_inactive_parts()
|
|
{
|
|
local table=$1
|
|
local database=${2:-$CLICKHOUSE_DATABASE}
|
|
local timeout=${3:-20}
|
|
|
|
while [[ timeout -gt 0 ]]
|
|
do
|
|
res=$(${CLICKHOUSE_CLIENT} --query="SELECT count() FROM system.parts WHERE database='$database' AND table='$table' AND not active")
|
|
[[ $res -eq 0 ]] && return 0
|
|
|
|
sleep 2
|
|
timeout=$((timeout - 2))
|
|
done
|
|
|
|
echo "Timed out while waiting for delete inactive parts!" >&2
|
|
return 2
|
|
}
|