2019-02-05 18:07:00 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
. $CURDIR /../shell_config.sh
. $CURDIR /mergetree_mutations.lib
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE IF EXISTS test.kill_mutation"
2019-02-05 18:07:00 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "CREATE TABLE test.kill_mutation(d Date, x UInt32, s String) ENGINE MergeTree ORDER BY x PARTITION BY d"
2019-02-05 18:07:00 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test.kill_mutation VALUES ('2000-01-01', 1, 'a')"
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test.kill_mutation VALUES ('2001-01-01', 2, 'b')"
2019-02-05 18:07:00 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT '*** Create and kill a single invalid mutation ***'"
2019-12-19 15:27:56 +00:00
${ CLICKHOUSE_CLIENT } --query= "ALTER TABLE test.kill_mutation DELETE WHERE toUInt32(s) = 1 SETTINGS mutations_sync = 1" &
2019-02-05 18:07:00 +00:00
2019-12-24 09:05:06 +00:00
check_query1 = "SELECT substr(latest_fail_reason, 1, 8) as ErrorCode FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation' AND ErrorCode != ''"
query_result = ` $CLICKHOUSE_CLIENT --query= " $check_query1 " 2>& 1`
while [ -z " $query_result " ]
do
query_result = ` $CLICKHOUSE_CLIENT --query= " $check_query1 " 2>& 1`
sleep 0.1
done
2019-12-17 13:03:23 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT mutation_id, latest_failed_part IN ('20000101_1_1_0', '20010101_2_2_0'), latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation'"
2019-02-05 18:07:00 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation'"
2019-02-05 18:07:00 +00:00
2019-12-19 15:27:56 +00:00
wait
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT mutation_id FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation'"
2019-02-05 18:07:00 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT '*** Create and kill invalid mutation that blocks another mutation ***'"
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "ALTER TABLE test.kill_mutation DELETE WHERE toUInt32(s) = 1"
2019-12-19 15:27:56 +00:00
${ CLICKHOUSE_CLIENT } --query= "ALTER TABLE test.kill_mutation DELETE WHERE x = 1 SETTINGS mutations_sync = 1" &
2019-02-05 18:07:00 +00:00
2019-12-24 09:05:06 +00:00
check_query2 = "SELECT substr(latest_fail_reason, 1, 8) as ErrorCode FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation' AND mutation_id = 'mutation_4.txt' AND ErrorCode != ''"
query_result = ` $CLICKHOUSE_CLIENT --query= " $check_query1 " 2>& 1`
while [ -z " $query_result " ]
do
query_result = ` $CLICKHOUSE_CLIENT --query= " $check_query1 " 2>& 1`
sleep 0.1
done
2019-12-17 13:03:23 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT mutation_id, latest_failed_part IN ('20000101_1_1_0', '20010101_2_2_0'), latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation' AND mutation_id = 'mutation_4.txt'"
2019-02-05 18:07:00 +00:00
2019-12-24 09:05:06 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation' AND mutation_id = 'mutation_4.txt'"
2019-02-05 18:07:00 +00:00
2019-12-19 15:27:56 +00:00
wait
2019-02-05 18:07:00 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "SELECT * FROM test.kill_mutation"
2019-02-05 18:07:00 +00:00
2019-04-18 18:48:04 +00:00
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE test.kill_mutation"