mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Make test 02473_optimize_old_parts less flaky
This commit is contained in:
parent
8bbfba39d5
commit
92046d7b56
@ -8,5 +8,3 @@ With merge replicated any part range
|
||||
1
|
||||
With merge replicated partition only
|
||||
1
|
||||
With merge partition only and new parts
|
||||
3
|
||||
|
91
tests/queries/0_stateless/02473_optimize_old_parts.sh
Executable file
91
tests/queries/0_stateless/02473_optimize_old_parts.sh
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: long
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Wait for number of parts in table $1 to become $2.
|
||||
# Print the changed value. If no changes for $3 seconds, prints initial value.
|
||||
wait_for_number_of_parts() {
|
||||
for _ in `seq $3`
|
||||
do
|
||||
sleep 1
|
||||
res=`$CLICKHOUSE_CLIENT -q "SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='$1' AND active"`
|
||||
if [ "$res" -eq "$2" ]
|
||||
then
|
||||
echo "$res"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE IF EXISTS test_without_merge;
|
||||
DROP TABLE IF EXISTS test_with_merge;
|
||||
DROP TABLE IF EXISTS test_replicated;
|
||||
|
||||
SELECT 'Without merge';
|
||||
|
||||
CREATE TABLE test_without_merge (i Int64) ENGINE = MergeTree ORDER BY i SETTINGS merge_selecting_sleep_ms=1000;
|
||||
INSERT INTO test_without_merge SELECT 1;
|
||||
INSERT INTO test_without_merge SELECT 2;
|
||||
INSERT INTO test_without_merge SELECT 3;"
|
||||
|
||||
wait_for_number_of_parts 'test_without_merge' 1 10
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE test_without_merge;
|
||||
|
||||
SELECT 'With merge any part range';
|
||||
|
||||
CREATE TABLE test_with_merge (i Int64) ENGINE = MergeTree ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=1, merge_selecting_sleep_ms=1000, min_age_to_force_merge_on_partition_only=false;
|
||||
INSERT INTO test_with_merge SELECT 1;
|
||||
INSERT INTO test_with_merge SELECT 2;
|
||||
INSERT INTO test_with_merge SELECT 3;"
|
||||
|
||||
wait_for_number_of_parts 'test_with_merge' 1 100
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE test_with_merge;
|
||||
|
||||
SELECT 'With merge partition only';
|
||||
|
||||
CREATE TABLE test_with_merge (i Int64) ENGINE = MergeTree ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=1, merge_selecting_sleep_ms=1000, min_age_to_force_merge_on_partition_only=true;
|
||||
INSERT INTO test_with_merge SELECT 1;
|
||||
INSERT INTO test_with_merge SELECT 2;
|
||||
INSERT INTO test_with_merge SELECT 3;"
|
||||
|
||||
wait_for_number_of_parts 'test_with_merge' 1 100
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE test_with_merge;
|
||||
|
||||
SELECT 'With merge replicated any part range';
|
||||
|
||||
CREATE TABLE test_replicated (i Int64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test02473', 'node') ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=1, merge_selecting_sleep_ms=1000, min_age_to_force_merge_on_partition_only=false;
|
||||
INSERT INTO test_replicated SELECT 1;
|
||||
INSERT INTO test_replicated SELECT 2;
|
||||
INSERT INTO test_replicated SELECT 3;"
|
||||
|
||||
wait_for_number_of_parts 'test_replicated' 1 100
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE test_replicated;
|
||||
|
||||
SELECT 'With merge replicated partition only';
|
||||
|
||||
CREATE TABLE test_replicated (i Int64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test02473_partition_only', 'node') ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=1, merge_selecting_sleep_ms=1000, min_age_to_force_merge_on_partition_only=true;
|
||||
INSERT INTO test_replicated SELECT 1;
|
||||
INSERT INTO test_replicated SELECT 2;
|
||||
INSERT INTO test_replicated SELECT 3;"
|
||||
|
||||
wait_for_number_of_parts 'test_replicated' 1 100
|
||||
|
||||
$CLICKHOUSE_CLIENT -nmq "
|
||||
DROP TABLE test_replicated;"
|
@ -1,87 +0,0 @@
|
||||
-- Tags: long
|
||||
|
||||
DROP TABLE IF EXISTS test_without_merge;
|
||||
DROP TABLE IF EXISTS test_with_merge;
|
||||
DROP TABLE IF EXISTS test_replicated;
|
||||
|
||||
SELECT 'Without merge';
|
||||
|
||||
CREATE TABLE test_without_merge (i Int64) ENGINE = MergeTree ORDER BY i;
|
||||
INSERT INTO test_without_merge SELECT 1;
|
||||
INSERT INTO test_without_merge SELECT 2;
|
||||
INSERT INTO test_without_merge SELECT 3;
|
||||
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_without_merge' AND active;
|
||||
|
||||
DROP TABLE test_without_merge;
|
||||
|
||||
SELECT 'With merge any part range';
|
||||
|
||||
CREATE TABLE test_with_merge (i Int64) ENGINE = MergeTree ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=3, min_age_to_force_merge_on_partition_only=false;
|
||||
INSERT INTO test_with_merge SELECT 1;
|
||||
INSERT INTO test_with_merge SELECT 2;
|
||||
INSERT INTO test_with_merge SELECT 3;
|
||||
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_with_merge' AND active;
|
||||
|
||||
DROP TABLE test_with_merge;
|
||||
|
||||
SELECT 'With merge partition only';
|
||||
|
||||
CREATE TABLE test_with_merge (i Int64) ENGINE = MergeTree ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=3, min_age_to_force_merge_on_partition_only=true;
|
||||
INSERT INTO test_with_merge SELECT 1;
|
||||
INSERT INTO test_with_merge SELECT 2;
|
||||
INSERT INTO test_with_merge SELECT 3;
|
||||
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_with_merge' AND active;
|
||||
|
||||
DROP TABLE test_with_merge;
|
||||
|
||||
SELECT 'With merge replicated any part range';
|
||||
|
||||
CREATE TABLE test_replicated (i Int64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test02473', 'node') ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=3, min_age_to_force_merge_on_partition_only=false;
|
||||
INSERT INTO test_replicated SELECT 1;
|
||||
INSERT INTO test_replicated SELECT 2;
|
||||
INSERT INTO test_replicated SELECT 3;
|
||||
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_replicated' AND active;
|
||||
|
||||
DROP TABLE test_replicated;
|
||||
|
||||
SELECT 'With merge replicated partition only';
|
||||
|
||||
CREATE TABLE test_replicated (i Int64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test02473_partition_only', 'node') ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=3, min_age_to_force_merge_on_partition_only=true;
|
||||
INSERT INTO test_replicated SELECT 1;
|
||||
INSERT INTO test_replicated SELECT 2;
|
||||
INSERT INTO test_replicated SELECT 3;
|
||||
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_replicated' AND active;
|
||||
|
||||
DROP TABLE test_replicated;
|
||||
|
||||
SELECT 'With merge partition only and new parts';
|
||||
|
||||
CREATE TABLE test_with_merge (i Int64) ENGINE = MergeTree ORDER BY i
|
||||
SETTINGS min_age_to_force_merge_seconds=3, min_age_to_force_merge_on_partition_only=true;
|
||||
SYSTEM STOP MERGES test_with_merge;
|
||||
-- These three parts will have min_age=6 at the time of merge
|
||||
INSERT INTO test_with_merge SELECT 1;
|
||||
INSERT INTO test_with_merge SELECT 2;
|
||||
SELECT sleepEachRow(1) FROM numbers(9) FORMAT Null;
|
||||
-- These three parts will have min_age=0 at the time of merge
|
||||
-- and so, nothing will be merged.
|
||||
INSERT INTO test_with_merge SELECT 3;
|
||||
SYSTEM START MERGES test_with_merge;
|
||||
|
||||
SELECT count(*) FROM system.parts WHERE database = currentDatabase() AND table='test_with_merge' AND active;
|
||||
|
||||
DROP TABLE test_with_merge;
|
Loading…
Reference in New Issue
Block a user