From 9c0da6e6989cd616d5bce535ae0a3f8e2a7d6521 Mon Sep 17 00:00:00 2001 From: Vitaliy Lyudvichenko Date: Mon, 26 Jun 2017 17:35:26 +0300 Subject: [PATCH] Addition to previous commit. Fix error code, rename test tables. [#CLICKHOUSE-2] --- .../Storages/StorageReplicatedMergeTree.cpp | 2 +- .../00446_clear_column_in_partition.sql | 58 +++++++++---------- ...46_clear_column_in_partition_concurrent.sh | 32 +++++----- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 7324d8f1e3b..b4618a3958c 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -2847,7 +2847,7 @@ AbandonableLockInZooKeeper StorageReplicatedMergeTree::allocateBlockNumber(const if (!existsNodeCached(month_path)) { int code = zookeeper->tryCreate(month_path, "", zkutil::CreateMode::Persistent); - if (code != ZOK && code != ZNONODE) + if (code != ZOK && code != ZNODEEXISTS) throw zkutil::KeeperException(code, month_path); } diff --git a/dbms/tests/queries/0_stateless/00446_clear_column_in_partition.sql b/dbms/tests/queries/0_stateless/00446_clear_column_in_partition.sql index 65cf0fbc020..41c9ab1ad06 100644 --- a/dbms/tests/queries/0_stateless/00446_clear_column_in_partition.sql +++ b/dbms/tests/queries/0_stateless/00446_clear_column_in_partition.sql @@ -1,53 +1,53 @@ -DROP TABLE IF EXISTS test.drop_column; -CREATE TABLE test.drop_column (d Date, num Int64, str String) ENGINE = MergeTree(d, d, 8192); +DROP TABLE IF EXISTS test.clear_column; +CREATE TABLE test.clear_column (d Date, num Int64, str String) ENGINE = MergeTree(d, d, 8192); -INSERT INTO test.drop_column VALUES ('2016-12-12', 1, 'a'), ('2016-11-12', 2, 'b'); +INSERT INTO test.clear_column VALUES ('2016-12-12', 1, 'a'), ('2016-11-12', 2, 'b'); -SELECT num, str FROM test.drop_column ORDER BY num; -ALTER TABLE test.drop_column CLEAR COLUMN num IN PARTITION '201612'; -SELECT num, str FROM test.drop_column ORDER BY num; +SELECT num, str FROM test.clear_column ORDER BY num; +ALTER TABLE test.clear_column CLEAR COLUMN num IN PARTITION '201612'; +SELECT num, str FROM test.clear_column ORDER BY num; -DROP TABLE test.drop_column; +DROP TABLE test.clear_column; -- Replicated case -DROP TABLE IF EXISTS test.drop_column1; -DROP TABLE IF EXISTS test.drop_column2; -CREATE TABLE test.drop_column1 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/drop_column', '1', d, d, 8192); -CREATE TABLE test.drop_column2 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/drop_column', '2', d, d, 8192); +DROP TABLE IF EXISTS test.clear_column1; +DROP TABLE IF EXISTS test.clear_column2; +CREATE TABLE test.clear_column1 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/clear_column', '1', d, d, 8192); +CREATE TABLE test.clear_column2 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/clear_column', '2', d, d, 8192); -INSERT INTO test.drop_column1 VALUES ('2000-01-01', 1, 'a'), ('2000-02-01', 2, 'b'); -INSERT INTO test.drop_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-02-01', 4, 'd'); +INSERT INTO test.clear_column1 VALUES ('2000-01-01', 1, 'a'), ('2000-02-01', 2, 'b'); +INSERT INTO test.clear_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-02-01', 4, 'd'); SELECT 'all'; -SELECT * FROM test.drop_column1 ORDER BY d, i, s; +SELECT * FROM test.clear_column1 ORDER BY d, i, s; SET replication_alter_partitions_sync=2; SELECT 'w/o i 1'; -ALTER TABLE test.drop_column1 CLEAR COLUMN i IN PARTITION '200001'; -SELECT * FROM test.drop_column2 ORDER BY d, i, s; +ALTER TABLE test.clear_column1 CLEAR COLUMN i IN PARTITION '200001'; +SELECT * FROM test.clear_column2 ORDER BY d, i, s; SELECT 'w/o is 1'; -ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200001'; -SELECT * FROM test.drop_column2 ORDER BY d, i, s; +ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200001'; +SELECT * FROM test.clear_column2 ORDER BY d, i, s; SELECT 'w/o is 12'; -ALTER TABLE test.drop_column1 CLEAR COLUMN i IN PARTITION '200002'; -ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200002'; -SELECT DISTINCT * FROM test.drop_column2 ORDER BY d, i, s; -SELECT DISTINCT * FROM test.drop_column2 ORDER BY d, i, s; +ALTER TABLE test.clear_column1 CLEAR COLUMN i IN PARTITION '200002'; +ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200002'; +SELECT DISTINCT * FROM test.clear_column2 ORDER BY d, i, s; +SELECT DISTINCT * FROM test.clear_column2 ORDER BY d, i, s; SELECT 'sizes'; -SELECT sum(data_uncompressed_bytes) FROM system.columns WHERE database='test' AND table LIKE 'drop_column_' AND (name = 'i' OR name = 's') GROUP BY table; +SELECT sum(data_uncompressed_bytes) FROM system.columns WHERE database='test' AND table LIKE 'clear_column_' AND (name = 'i' OR name = 's') GROUP BY table; -- double call should be OK -ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200001'; -ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200002'; +ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200001'; +ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200002'; -- check optimize for non-leader replica -OPTIMIZE TABLE test.drop_column1; -OPTIMIZE TABLE test.drop_column2; +OPTIMIZE TABLE test.clear_column1; +OPTIMIZE TABLE test.clear_column2; -DROP TABLE IF EXISTS test.drop_column1; -DROP TABLE IF EXISTS test.drop_column2; +DROP TABLE IF EXISTS test.clear_column1; +DROP TABLE IF EXISTS test.clear_column2; diff --git a/dbms/tests/queries/0_stateless/00446_clear_column_in_partition_concurrent.sh b/dbms/tests/queries/0_stateless/00446_clear_column_in_partition_concurrent.sh index 4cb306d1d5a..972fde93131 100755 --- a/dbms/tests/queries/0_stateless/00446_clear_column_in_partition_concurrent.sh +++ b/dbms/tests/queries/0_stateless/00446_clear_column_in_partition_concurrent.sh @@ -3,26 +3,26 @@ set -e ch="clickhouse-client --stacktrace -q" -$ch "DROP TABLE IF EXISTS test.drop_column1" -$ch "DROP TABLE IF EXISTS test.drop_column2" -$ch "CREATE TABLE test.drop_column1 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/drop_column', '1', d, d, 8192)" -$ch "CREATE TABLE test.drop_column2 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/drop_column', '2', d, d, 8192)" +$ch "DROP TABLE IF EXISTS test.clear_column1" +$ch "DROP TABLE IF EXISTS test.clear_column2" +$ch "CREATE TABLE test.clear_column1 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/clear_column', '1', d, d, 8192)" +$ch "CREATE TABLE test.clear_column2 (d Date, i Int64, s String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/clear_column', '2', d, d, 8192)" -$ch "INSERT INTO test.drop_column1 VALUES ('2000-01-01', 1, 'a'), ('2000-02-01', 2, 'b')" -$ch "INSERT INTO test.drop_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-02-01', 4, 'd')" +$ch "INSERT INTO test.clear_column1 VALUES ('2000-01-01', 1, 'a'), ('2000-02-01', 2, 'b')" +$ch "INSERT INTO test.clear_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-02-01', 4, 'd')" for i in `seq 3`; do - $ch "INSERT INTO test.drop_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-01-01', 4, 'd')" & # insert into the same partition - $ch "ALTER TABLE test.drop_column1 CLEAR COLUMN i IN PARTITION '200001'" --replication_alter_partitions_sync=2 & - $ch "ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200001'" --replication_alter_partitions_sync=2 & - $ch "ALTER TABLE test.drop_column1 CLEAR COLUMN i IN PARTITION '200002'" --replication_alter_partitions_sync=2 & - $ch "ALTER TABLE test.drop_column1 CLEAR COLUMN s IN PARTITION '200002'" --replication_alter_partitions_sync=2 & - $ch "INSERT INTO test.drop_column1 VALUES ('2000-03-01', 3, 'c'), ('2000-03-01', 4, 'd')" & # insert into other partition + $ch "INSERT INTO test.clear_column1 VALUES ('2000-01-01', 3, 'c'), ('2000-01-01', 4, 'd')" & # insert into the same partition + $ch "ALTER TABLE test.clear_column1 CLEAR COLUMN i IN PARTITION '200001'" --replication_alter_partitions_sync=2 & + $ch "ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200001'" --replication_alter_partitions_sync=2 & + $ch "ALTER TABLE test.clear_column1 CLEAR COLUMN i IN PARTITION '200002'" --replication_alter_partitions_sync=2 & + $ch "ALTER TABLE test.clear_column1 CLEAR COLUMN s IN PARTITION '200002'" --replication_alter_partitions_sync=2 & + $ch "INSERT INTO test.clear_column1 VALUES ('2000-03-01', 3, 'c'), ('2000-03-01', 4, 'd')" & # insert into other partition done wait -$ch "SELECT DISTINCT * FROM test.drop_column2 WHERE d != toDate('2000-03-01') ORDER BY d, i, s" -$ch "SELECT DISTINCT * FROM test.drop_column2 WHERE d != toDate('2000-03-01') ORDER BY d, i, s" +$ch "SELECT DISTINCT * FROM test.clear_column2 WHERE d != toDate('2000-03-01') ORDER BY d, i, s" +$ch "SELECT DISTINCT * FROM test.clear_column2 WHERE d != toDate('2000-03-01') ORDER BY d, i, s" -$ch "DROP TABLE IF EXISTS test.drop_column1" -$ch "DROP TABLE IF EXISTS test.drop_column2" +$ch "DROP TABLE IF EXISTS test.clear_column1" +$ch "DROP TABLE IF EXISTS test.clear_column2"