Improve tests for ALTER MOVE

This commit is contained in:
Alexey Milovidov 2020-05-13 03:02:53 +03:00
parent 88039e8371
commit 2800df4450
2 changed files with 54 additions and 54 deletions

View File

@ -22,77 +22,77 @@ function query_with_retry
echo "Query '$1' failed with '$result'"
}
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS $CLICKHOUSE_DATABASE.src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS $CLICKHOUSE_DATABASE.dst NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS dst NO DELAY;"
sleep 1
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY k;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.dst (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY k SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY k;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE dst (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY k SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (2, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (2, '0', 1);"
$CLICKHOUSE_CLIENT --query="SELECT 'Initial';"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.dst VALUES (0, '1', 2);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.dst VALUES (1, '1', 2), (1, '2', 2);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.dst VALUES (2, '1', 2);"
$CLICKHOUSE_CLIENT --query="INSERT INTO dst VALUES (0, '1', 2);"
$CLICKHOUSE_CLIENT --query="INSERT INTO dst VALUES (1, '1', 2), (1, '2', 2);"
$CLICKHOUSE_CLIENT --query="INSERT INTO dst VALUES (2, '1', 2);"
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM dst;"
$CLICKHOUSE_CLIENT --query="SELECT 'MOVE simple';"
query_with_retry "ALTER TABLE $CLICKHOUSE_DATABASE.src MOVE PARTITION 1 TO TABLE $CLICKHOUSE_DATABASE.dst;"
query_with_retry "ALTER TABLE src MOVE PARTITION 1 TO TABLE dst;"
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM dst;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.dst NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE dst NO DELAY;"
sleep 1
$CLICKHOUSE_CLIENT --query="SELECT 'MOVE incompatible schema missing column';"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY (d, p);"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.dst (p UInt64, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY (d, p) SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY (d, p);"
$CLICKHOUSE_CLIENT --query="CREATE TABLE dst (p UInt64, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY (d, p) SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (2, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (2, '0', 1);"
query_with_retry "ALTER TABLE $CLICKHOUSE_DATABASE.src MOVE PARTITION 1 TO TABLE $CLICKHOUSE_DATABASE.dst;" &>-
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA $CLICKHOUSE_DATABASE.dst;"
query_with_retry "ALTER TABLE src MOVE PARTITION 1 TO TABLE dst;" &>-
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM dst;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.dst NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE dst NO DELAY;"
sleep 1
$CLICKHOUSE_CLIENT --query="SELECT 'MOVE incompatible schema different order by';"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY (p, k, d);"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.dst (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY (d, k, p);"
$CLICKHOUSE_CLIENT --query="CREATE TABLE src (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY (p, k, d);"
$CLICKHOUSE_CLIENT --query="CREATE TABLE dst (p UInt64, k String, d UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY (d, k, p);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src VALUES (2, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (0, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '0', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (1, '1', 1);"
$CLICKHOUSE_CLIENT --query="INSERT INTO src VALUES (2, '0', 1);"
query_with_retry "ALTER TABLE $CLICKHOUSE_DATABASE.src MOVE PARTITION 1 TO TABLE $CLICKHOUSE_DATABASE.dst;" &>-
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA $CLICKHOUSE_DATABASE.dst;"
query_with_retry "ALTER TABLE src MOVE PARTITION 1 TO TABLE dst;" &>-
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM src;"
$CLICKHOUSE_CLIENT --query="SELECT count(), sum(d) FROM dst;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE $CLICKHOUSE_DATABASE.dst NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE src NO DELAY;"
$CLICKHOUSE_CLIENT --query="DROP TABLE dst NO DELAY;"
sleep 1

View File

@ -5,17 +5,17 @@ set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS $CLICKHOUSE_DATABASE.src;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS $CLICKHOUSE_DATABASE.dst;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS src;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS dst;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.src (p UInt64, k String) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY k;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE $CLICKHOUSE_DATABASE.dst (p UInt64, k String) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY k SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE src (p UInt64, k String) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/src', '1') PARTITION BY p ORDER BY k;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE dst (p UInt64, k String) ENGINE = ReplicatedMergeTree('/clickhouse/$CLICKHOUSE_DATABASE/dst', '1') PARTITION BY p ORDER BY k SETTINGS old_parts_lifetime=1, cleanup_delay_period=1, cleanup_delay_period_random_add=0;"
function thread1()
{
while true;
do
$CLICKHOUSE_CLIENT --query="ALTER TABLE $CLICKHOUSE_DATABASE.src MOVE PARTITION 1 TO TABLE $CLICKHOUSE_DATABASE.dst;" --query_id=query1
$CLICKHOUSE_CLIENT --query="ALTER TABLE src MOVE PARTITION 1 TO TABLE dst;" --query_id=query1
done
}
@ -23,7 +23,7 @@ function thread2()
{
while true;
do
$CLICKHOUSE_CLIENT --query="INSERT INTO $CLICKHOUSE_DATABASE.src SELECT number % 2, toString(number) FROM system.numbers LIMIT 100000" --query_id=query2
$CLICKHOUSE_CLIENT --query="INSERT INTO src SELECT number % 2, toString(number) FROM system.numbers LIMIT 100000" --query_id=query2
done
}
@ -31,7 +31,7 @@ function thread3()
{
while true;
do
$CLICKHOUSE_CLIENT --query="SELECT * FROM $CLICKHOUSE_DATABASE.src" --query_id=query3 1> /dev/null
$CLICKHOUSE_CLIENT --query="SELECT * FROM src" --query_id=query3 1> /dev/null
done
}
@ -39,7 +39,7 @@ function thread4()
{
while true;
do
$CLICKHOUSE_CLIENT --query="SELECT * FROM $CLICKHOUSE_DATABASE.dst" --query_id=query4 1> /dev/null
$CLICKHOUSE_CLIENT --query="SELECT * FROM dst" --query_id=query4 1> /dev/null
done
}
@ -58,8 +58,8 @@ timeout $TIMEOUT bash -c thread4 2> /dev/null &
wait
echo "DROP TABLE $CLICKHOUSE_DATABASE.src NO DELAY" | ${CLICKHOUSE_CLIENT}
echo "DROP TABLE $CLICKHOUSE_DATABASE.dst NO DELAY" | ${CLICKHOUSE_CLIENT}
echo "DROP TABLE src NO DELAY" | ${CLICKHOUSE_CLIENT}
echo "DROP TABLE dst NO DELAY" | ${CLICKHOUSE_CLIENT}
sleep 5
# Check for deadlocks