mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
61 lines
1.2 KiB
Bash
Executable File
61 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
. $CURDIR/../shell_config.sh
|
|
|
|
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
|
DROP TABLE IF EXISTS src;
|
|
DROP TABLE IF EXISTS mv;
|
|
|
|
CREATE TABLE src(v UInt64) ENGINE = Null;
|
|
CREATE MATERIALIZED VIEW mv(v UInt8) Engine = MergeTree() ORDER BY v AS SELECT v FROM src;
|
|
EOF
|
|
|
|
# Test that ALTER doesn't cause data loss or duplication.
|
|
#
|
|
# Idea for future:
|
|
#
|
|
# null
|
|
# / \
|
|
# mv1 mv2
|
|
# \ /
|
|
# \ /
|
|
# mv sink
|
|
#
|
|
# Insert N times into null while altering sink query and switching it from mv1 to mv2.
|
|
|
|
function alter_thread()
|
|
{
|
|
trap 'exit' INT
|
|
|
|
ALTERS[0]="ALTER TABLE mv MODIFY QUERY SELECT v FROM src;"
|
|
ALTERS[1]="ALTER TABLE mv MODIFY QUERY SELECT v * 2 as v FROM src;"
|
|
|
|
while true; do
|
|
$CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 -q "${ALTERS[$RANDOM % 2]}"
|
|
sleep `echo 0.$RANDOM`;
|
|
done
|
|
}
|
|
|
|
alter_thread &
|
|
alter_pid=$!
|
|
|
|
for i in $(seq 1 100); do
|
|
(
|
|
# Retry (hopefully retriable (deadlock avoided)) errors.
|
|
until false; do
|
|
$CLICKHOUSE_CLIENT -q "INSERT INTO src VALUES (1);" 2>/dev/null && break
|
|
done
|
|
)
|
|
done
|
|
|
|
# Enough alters.
|
|
kill -INT $alter_pid
|
|
|
|
wait
|
|
|
|
# This was a fun ride.
|
|
$CLICKHOUSE_CLIENT -q "SELECT count() FROM mv;"
|