mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 13:13:36 +00:00
c25d6cd624
* Limit log frequence for "Skipping send data over distributed table" message After SYSTEM STOP DISTRIBUTED SENDS it will constantly print this message. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Rename directory monitor concept into async INSERT Rename the following query settings (with preserving backward compatiblity, by keeping old name as an alias): - distributed_directory_monitor_sleep_time_ms -> distributed_async_insert_sleep_time_ms - distributed_directory_monitor_max_sleep_time_ms -> distributed_async_insert_max_sleep_time_ms - distributed_directory_monitor_batch -> distributed_async_insert_batch_inserts - distributed_directory_monitor_split_batch_on_failure -> distributed_async_insert_split_batch_on_failure Rename the following table settings (with preserving backward compatiblity, by keeping old name as an alias): - monitor_batch_inserts -> async_insert_batch - monitor_split_batch_on_failure -> async_insert_split_batch_on_failure - directory_monitor_sleep_time_ms -> async_insert_sleep_time_ms - directory_monitor_max_sleep_time_ms -> async_insert_max_sleep_time_ms And also update all the references: $ gg -e directory_monitor_ -e monitor_ tests docs | cut -d: -f1 | sort -u | xargs sed -e 's/distributed_directory_monitor_sleep_time_ms/distributed_async_insert_sleep_time_ms/g' -e 's/distributed_directory_monitor_max_sleep_time_ms/distributed_async_insert_max_sleep_time_ms/g' -e 's/distributed_directory_monitor_batch_inserts/distributed_async_insert_batch/g' -e 's/distributed_directory_monitor_split_batch_on_failure/distributed_async_insert_split_batch_on_failure/g' -e 's/monitor_batch_inserts/async_insert_batch/g' -e 's/monitor_split_batch_on_failure/async_insert_split_batch_on_failure/g' -e 's/monitor_sleep_time_ms/async_insert_sleep_time_ms/g' -e 's/monitor_max_sleep_time_ms/async_insert_max_sleep_time_ms/g' -i Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Rename async_insert for Distributed into background_insert This will avoid amigibuity between general async INSERT's and INSERT into Distributed, which are indeed background, so new term express it even better. Mostly done with: $ git di HEAD^ --name-only | xargs sed -i -e 's/distributed_async_insert/distributed_background_insert/g' -e 's/async_insert_batch/background_insert_batch/g' -e 's/async_insert_split_batch_on_failure/background_insert_split_batch_on_failure/g' -e 's/async_insert_sleep_time_ms/background_insert_sleep_time_ms/g' -e 's/async_insert_max_sleep_time_ms/background_insert_max_sleep_time_ms/g' Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Mark 02417_opentelemetry_insert_on_distributed_table as long CI: https://s3.amazonaws.com/clickhouse-test-reports/55978/7a6abb03a0b507e29e999cb7e04f246a119c6f28/stateless_tests_flaky_check__asan_.html Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> --------- Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
172 lines
6.6 KiB
Python
172 lines
6.6 KiB
Python
import pytest
|
|
from helpers.cluster import ClickHouseCluster
|
|
from helpers.test_tools import assert_eq_with_retry
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
node1 = cluster.add_instance(
|
|
"node1",
|
|
main_configs=["configs/remote_servers.xml"],
|
|
user_configs=["configs/settings.xml"],
|
|
with_zookeeper=True,
|
|
macros={"shard": 1, "replica": 1, "shard_bk": 3, "replica_bk": 2},
|
|
)
|
|
node2 = cluster.add_instance(
|
|
"node2",
|
|
main_configs=["configs/remote_servers.xml"],
|
|
user_configs=["configs/settings.xml"],
|
|
with_zookeeper=True,
|
|
macros={"shard": 2, "replica": 1, "shard_bk": 1, "replica_bk": 2},
|
|
)
|
|
node3 = cluster.add_instance(
|
|
"node3",
|
|
main_configs=["configs/remote_servers.xml"],
|
|
user_configs=["configs/settings.xml"],
|
|
with_zookeeper=True,
|
|
macros={"shard": 3, "replica": 1, "shard_bk": 2, "replica_bk": 2},
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def started_cluster():
|
|
try:
|
|
cluster.start()
|
|
|
|
node1.query(
|
|
"""
|
|
CREATE DATABASE replica_1 ON CLUSTER cross_3shards_2replicas;
|
|
CREATE DATABASE replica_2 ON CLUSTER cross_3shards_2replicas;
|
|
|
|
CREATE TABLE replica_1.replicated_local
|
|
ON CLUSTER cross_3shards_2replicas (part_key Date, id UInt32, shard_id UInt32)
|
|
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/replicated', '{replica}')
|
|
partition by part_key order by id;
|
|
|
|
CREATE TABLE replica_1.replicated
|
|
ON CLUSTER cross_3shards_2replicas as replica_1.replicated_local
|
|
ENGINE = Distributed(cross_3shards_2replicas, '', replicated_local, shard_id);
|
|
|
|
CREATE TABLE replica_2.replicated_local
|
|
ON CLUSTER cross_3shards_2replicas (part_key Date, id UInt32, shard_id UInt32)
|
|
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard_bk}/replicated', '{replica_bk}')
|
|
partition by part_key order by id;
|
|
|
|
CREATE TABLE replica_2.replicated
|
|
ON CLUSTER cross_3shards_2replicas as replica_2.replicated_local
|
|
ENGINE = Distributed(cross_3shards_2replicas, '', replicated_local, shard_id);
|
|
"""
|
|
)
|
|
|
|
to_insert = """\
|
|
2017-06-16 10 0
|
|
2017-06-17 11 0
|
|
2017-06-16 20 1
|
|
2017-06-17 21 1
|
|
2017-06-16 30 2
|
|
2017-06-17 31 2
|
|
"""
|
|
|
|
node1.query(
|
|
"INSERT INTO replica_1.replicated FORMAT TSV",
|
|
stdin=to_insert,
|
|
settings={"distributed_foreground_insert": 1},
|
|
)
|
|
yield cluster
|
|
|
|
finally:
|
|
# pass
|
|
cluster.shutdown()
|
|
|
|
|
|
def test_alter_ddl(started_cluster):
|
|
node1.query(
|
|
"ALTER TABLE replica_1.replicated_local \
|
|
ON CLUSTER cross_3shards_2replicas \
|
|
UPDATE shard_id=shard_id+3 \
|
|
WHERE part_key='2017-06-16'"
|
|
)
|
|
|
|
node1.query("SYSTEM SYNC REPLICA replica_2.replicated_local;", timeout=5)
|
|
assert_eq_with_retry(
|
|
node1,
|
|
"SELECT count(*) FROM replica_2.replicated where shard_id >= 3 and part_key='2017-06-16'",
|
|
"3",
|
|
)
|
|
|
|
node1.query(
|
|
"ALTER TABLE replica_1.replicated_local \
|
|
ON CLUSTER cross_3shards_2replicas DELETE WHERE shard_id >=3;"
|
|
)
|
|
node1.query("SYSTEM SYNC REPLICA replica_2.replicated_local;", timeout=5)
|
|
assert_eq_with_retry(
|
|
node1, "SELECT count(*) FROM replica_2.replicated where shard_id >= 3", "0"
|
|
)
|
|
|
|
node2.query(
|
|
"ALTER TABLE replica_1.replicated_local ON CLUSTER cross_3shards_2replicas DROP PARTITION '2017-06-17'"
|
|
)
|
|
|
|
node2.query("SYSTEM SYNC REPLICA replica_2.replicated_local;", timeout=5)
|
|
assert_eq_with_retry(node1, "SELECT count(*) FROM replica_2.replicated", "0")
|
|
|
|
|
|
def test_atomic_database(started_cluster):
|
|
node1.query(
|
|
"""DROP DATABASE IF EXISTS replica_1 ON CLUSTER cross_3shards_2replicas;
|
|
DROP DATABASE IF EXISTS replica_2 ON CLUSTER cross_3shards_2replicas;
|
|
CREATE DATABASE replica_1 ON CLUSTER cross_3shards_2replicas ENGINE=Atomic;
|
|
CREATE DATABASE replica_2 ON CLUSTER cross_3shards_2replicas ENGINE=Atomic;"""
|
|
)
|
|
|
|
assert "It's not supported for cross replication" in node1.query_and_get_error(
|
|
"CREATE TABLE rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree ORDER BY n"
|
|
)
|
|
assert "It's not supported for cross replication" in node1.query_and_get_error(
|
|
"CREATE TABLE replica_1.rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree ORDER BY n"
|
|
)
|
|
assert "It's not supported for cross replication" in node1.query_and_get_error(
|
|
"CREATE TABLE rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree('/{shard}/{uuid}/', '{replica}') ORDER BY n"
|
|
)
|
|
assert "It's not supported for cross replication" in node1.query_and_get_error(
|
|
"CREATE TABLE replica_2.rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree('/{shard}/{uuid}/', '{replica}') ORDER BY n"
|
|
)
|
|
assert (
|
|
"For a distributed DDL on circular replicated cluster its table name must be qualified by database name"
|
|
in node1.query_and_get_error(
|
|
"CREATE TABLE rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree('/tables/{shard}/rmt/', '{replica}') ORDER BY n"
|
|
)
|
|
)
|
|
|
|
node1.query(
|
|
"CREATE TABLE replica_1.rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree('/tables/{shard}/rmt/', '{replica}') ORDER BY n"
|
|
)
|
|
node1.query(
|
|
"CREATE TABLE replica_2.rmt ON CLUSTER cross_3shards_2replicas (n UInt64, s String) ENGINE=ReplicatedMergeTree('/tables/{shard_bk}/rmt/', '{replica_bk}') ORDER BY n"
|
|
)
|
|
|
|
assert (
|
|
node1.query(
|
|
"SELECT countDistinct(uuid) from remote('node1,node2,node3', 'system', 'databases') WHERE uuid != '00000000-0000-0000-0000-000000000000' AND name='replica_1'"
|
|
)
|
|
== "1\n"
|
|
)
|
|
assert (
|
|
node1.query(
|
|
"SELECT countDistinct(uuid) from remote('node1,node2,node3', 'system', 'tables') WHERE uuid != '00000000-0000-0000-0000-000000000000' AND name='rmt'"
|
|
)
|
|
== "2\n"
|
|
)
|
|
|
|
node1.query("INSERT INTO replica_1.rmt VALUES (1, 'test')")
|
|
node2.query("SYSTEM SYNC REPLICA replica_2.rmt", timeout=5)
|
|
assert_eq_with_retry(node2, "SELECT * FROM replica_2.rmt", "1\ttest")
|
|
|
|
|
|
def test_non_query_with_table_ddl(started_cluster):
|
|
node1.query("CREATE USER A ON CLUSTER cross_3shards_2replicas")
|
|
|
|
assert node1.query("SELECT 1", user="A") == "1\n"
|
|
assert node2.query("SELECT 1", user="A") == "1\n"
|
|
|
|
node2.query("DROP USER A ON CLUSTER cross_3shards_2replicas")
|