From ba53f61208c49ea2052db7f2e6753fc689d7a007 Mon Sep 17 00:00:00 2001 From: Alexey Zatelepin Date: Tue, 5 Feb 2019 21:07:00 +0300 Subject: [PATCH] KILL MUTATION tests [#CLICKHOUSE-3912] --- .../0_stateless/00834_kill_mutation.reference | 8 ++++ .../0_stateless/00834_kill_mutation.sh | 42 +++++++++++++++++ ...ll_mutation_replicated_zookeeper.reference | 8 ++++ ...0834_kill_mutation_replicated_zookeeper.sh | 46 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00834_kill_mutation.reference create mode 100755 dbms/tests/queries/0_stateless/00834_kill_mutation.sh create mode 100644 dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.reference create mode 100755 dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.sh diff --git a/dbms/tests/queries/0_stateless/00834_kill_mutation.reference b/dbms/tests/queries/0_stateless/00834_kill_mutation.reference new file mode 100644 index 00000000000..1edb3772c7f --- /dev/null +++ b/dbms/tests/queries/0_stateless/00834_kill_mutation.reference @@ -0,0 +1,8 @@ +*** Create and kill a single invalid mutation *** +mutation_3.txt 20000101_1_1_0 1 Code: 6, +waiting test kill_mutation mutation_3.txt +*** Create and kill invalid mutation that blocks another mutation *** +mutation_4.txt 20000101_1_1_0 1 Code: 6, +mutation_5.txt 20000101_1_1_0 1 Code: 6, +waiting test kill_mutation mutation_4.txt +2001-01-01 2 b diff --git a/dbms/tests/queries/0_stateless/00834_kill_mutation.sh b/dbms/tests/queries/0_stateless/00834_kill_mutation.sh new file mode 100755 index 00000000000..a933c8490e6 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00834_kill_mutation.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +. $CURDIR/mergetree_mutations.lib + +${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS test.kill_mutation" + +${CLICKHOUSE_CLIENT} --query="CREATE TABLE test.kill_mutation(d Date, x UInt32, s String) ENGINE MergeTree ORDER BY x PARTITION BY d" + +${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')" + +${CLICKHOUSE_CLIENT} --query="SELECT '*** Create and kill a single invalid mutation ***'" + +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation DELETE WHERE toUInt32(s) = 1" + +sleep 0.1 +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id, latest_failed_part, latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation' ORDER BY mutation_id" + +${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation'" + +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation'" + + +${CLICKHOUSE_CLIENT} --query="SELECT '*** Create and kill invalid mutation that blocks another mutation ***'" + +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation DELETE WHERE toUInt32(s) = 1" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation DELETE WHERE x = 1" + +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id, latest_failed_part, latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation' ORDER BY mutation_id" + +sleep 0.1 +${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation' AND mutation_id = 'mutation_4.txt'" + +wait_for_mutation "kill_mutation" "mutation_5.txt" + +${CLICKHOUSE_CLIENT} --query="SELECT * FROM test.kill_mutation" + + +${CLICKHOUSE_CLIENT} --query="DROP TABLE test.kill_mutation" diff --git a/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.reference b/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.reference new file mode 100644 index 00000000000..7296c410697 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.reference @@ -0,0 +1,8 @@ +*** Create and kill a single invalid mutation *** +0000000000 1 1 Code: 6, +waiting test kill_mutation_r1 0000000000 +*** Create and kill invalid mutation that blocks another mutation *** +0000000001 1 1 Code: 6, +0000000002 1 1 Code: 6, +waiting test kill_mutation_r1 0000000001 +2001-01-01 2 b diff --git a/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.sh b/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.sh new file mode 100755 index 00000000000..91f8710d12d --- /dev/null +++ b/dbms/tests/queries/0_stateless/00834_kill_mutation_replicated_zookeeper.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +. $CURDIR/mergetree_mutations.lib + +${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS test.kill_mutation_r1" +${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS test.kill_mutation_r2" + +${CLICKHOUSE_CLIENT} --query="CREATE TABLE test.kill_mutation_r1(d Date, x UInt32, s String) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/kill_mutation', '1') ORDER BY x PARTITION BY d" +${CLICKHOUSE_CLIENT} --query="CREATE TABLE test.kill_mutation_r2(d Date, x UInt32, s String) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/kill_mutation', '2') ORDER BY x PARTITION BY d" + +${CLICKHOUSE_CLIENT} --query="INSERT INTO test.kill_mutation_r1 VALUES ('2000-01-01', 1, 'a')" +${CLICKHOUSE_CLIENT} --query="INSERT INTO test.kill_mutation_r1 VALUES ('2001-01-01', 2, 'b')" + + +${CLICKHOUSE_CLIENT} --query="SELECT '*** Create and kill a single invalid mutation ***'" + +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation_r1 DELETE WHERE toUInt32(s) = 1" + +sleep 1 +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id, latest_failed_part != '', latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation_r1' ORDER BY mutation_id" + +${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation_r1'" + +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation_r1'" + + +${CLICKHOUSE_CLIENT} --query="SELECT '*** Create and kill invalid mutation that blocks another mutation ***'" + +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation_r1 DELETE WHERE toUInt32(s) = 1" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation_r1 DELETE WHERE x = 1" + +sleep 1 +${CLICKHOUSE_CLIENT} --query="SELECT mutation_id, latest_failed_part != '', latest_fail_time != 0, substr(latest_fail_reason, 1, 8) FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation_r1' ORDER BY mutation_id" + +${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table = 'kill_mutation_r1' AND mutation_id = '0000000001'" + +wait_for_mutation "kill_mutation_r2" "0000000002" + +${CLICKHOUSE_CLIENT} --query="SELECT * FROM test.kill_mutation_r2" + + +${CLICKHOUSE_CLIENT} --query="DROP TABLE test.kill_mutation_r1" +${CLICKHOUSE_CLIENT} --query="DROP TABLE test.kill_mutation_r2"