Added a test to ensure that amount of ZooKeeper nodes do not grow in presense of lost replicas

This commit is contained in:
Alexey Milovidov 2020-07-15 02:00:45 +03:00
parent ffe2cecb1b
commit 36436eb703
2 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,58 @@
block_numbers 1
blocks 0
columns 1
leader_election 1
log 0
metadata 1
mutations 1
nonincrement_block_numbers 1
quorum 1
replicas 1
temp 1
---
columns 1
flags 1
host 1
is_active 1
is_lost 1 0
log_pointer 1
max_processed_insert_time 1
metadata 1
metadata_version 1
min_unprocessed_insert_time 1
mutation_pointer 1
parts 0
queue 1
---
columns 1
flags 1
host 1
is_lost 1 1
log_pointer 1
max_processed_insert_time 1
metadata 1
metadata_version 1
min_unprocessed_insert_time 1
mutation_pointer 1
parts 1
queue 1
---
columns 1
flags 1
host 1
is_active 1
is_lost 1 0
log_pointer 1
max_processed_insert_time 1
metadata 1
metadata_version 1
min_unprocessed_insert_time 1
mutation_pointer 1
parts 1
queue 1

View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
# Check that if we have one inactive replica and a huge number of INSERTs to active replicas,
# the number of nodes in ZooKeeper does not grow unbounded.
$CLICKHOUSE_CLIENT -n --query "
DROP TABLE IF EXISTS r1;
DROP TABLE IF EXISTS r2;
CREATE TABLE r1 (x UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/r', '1') ORDER BY x SETTINGS old_parts_lifetime = 1, cleanup_delay_period = 1, cleanup_delay_period_random_add = 1, parts_to_throw_insert = 100000, max_replicated_logs_to_keep = 10;
CREATE TABLE r2 (x UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/r', '2') ORDER BY x SETTINGS old_parts_lifetime = 1, cleanup_delay_period = 1, cleanup_delay_period_random_add = 1, parts_to_throw_insert = 100000, max_replicated_logs_to_keep = 10;
DETACH TABLE r2;
"
$CLICKHOUSE_CLIENT --max_block_size 1 --min_insert_block_size_rows 1 --min_insert_block_size_bytes 1 --max_insert_threads 16 --query "INSERT INTO r1 SELECT * FROM numbers_mt(10000)"
$CLICKHOUSE_CLIENT --query "SELECT name, numChildren < 1000 FROM system.zookeeper WHERE path = '/clickhouse/tables/r'";
echo -e '\n---\n';
$CLICKHOUSE_CLIENT --query "SELECT name, numChildren < 1000, name = 'is_lost' ? value : '' FROM system.zookeeper WHERE path = '/clickhouse/tables/r/replicas/1'";
echo -e '\n---\n';
$CLICKHOUSE_CLIENT --query "SELECT name, numChildren < 1000, name = 'is_lost' ? value : '' FROM system.zookeeper WHERE path = '/clickhouse/tables/r/replicas/2'";
echo -e '\n---\n';
$CLICKHOUSE_CLIENT --query "ATTACH TABLE r2"
$CLICKHOUSE_CLIENT --query "SYSTEM SYNC REPLICA r2"
$CLICKHOUSE_CLIENT --query "SELECT name, numChildren < 1000, name = 'is_lost' ? value : '' FROM system.zookeeper WHERE path = '/clickhouse/tables/r/replicas/2'";
$CLICKHOUSE_CLIENT -n --query "
DROP TABLE IF EXISTS r1;
DROP TABLE IF EXISTS r2;
"