2022-09-22 22:51:13 +00:00
|
|
|
#!/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
|
|
|
|
|
2022-10-19 10:41:25 +00:00
|
|
|
sleep 2
|
|
|
|
timeout=$((timeout - 2))
|
2022-09-22 22:51:13 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "Timed out while waiting for delete empty parts!" >&2
|
|
|
|
return 2
|
|
|
|
}
|
2022-10-13 16:07:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-10-19 10:41:25 +00:00
|
|
|
sleep 2
|
|
|
|
timeout=$((timeout - 2))
|
2022-10-13 16:07:25 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "Timed out while waiting for delete inactive parts!" >&2
|
|
|
|
return 2
|
|
|
|
}
|
2022-12-02 13:09:04 +00:00
|
|
|
|
|
|
|
export -f wait_for_delete_empty_parts
|
|
|
|
export -f wait_for_delete_inactive_parts
|
2023-08-18 09:17:32 +00:00
|
|
|
|
|
|
|
# vi: ft=bash
|