mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Throw on ordinary db engine
This commit is contained in:
parent
68cf2a6b60
commit
6f79f98719
@ -80,6 +80,10 @@ void DatabaseOrdinary::convertMergeTreeToReplicatedIfNeeded(ASTPtr ast, const Qu
|
||||
if (!fs::exists(convert_to_replicated_flag_path))
|
||||
return;
|
||||
|
||||
if (getUUID() == UUIDHelpers::Nil)
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
|
||||
"Table engine conversion to replicated is supported only for Atomic databases. Convert your database engine to Atomic first.");
|
||||
|
||||
LOG_INFO(log, "Found convert_to_replicated flag for table {}. Will try to change it's engine in metadata to replicated table.", backQuote(qualified_name.getFullName()));
|
||||
|
||||
/// Get storage definition
|
||||
|
106
tests/integration/test_modify_engine_on_restart/test_ordinary.py
Normal file
106
tests/integration/test_modify_engine_on_restart/test_ordinary.py
Normal file
@ -0,0 +1,106 @@
|
||||
import pytest
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
ch1 = cluster.add_instance(
|
||||
"ch1",
|
||||
main_configs=[
|
||||
"configs/config.d/clusters.xml",
|
||||
"configs/config.d/distributed_ddl.xml",
|
||||
],
|
||||
with_zookeeper=True,
|
||||
macros={"replica": "node1"},
|
||||
stay_alive=True,
|
||||
)
|
||||
|
||||
database_name = "modify_engine_on_ordinary"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def q(node, query):
|
||||
return node.query(database=database_name, sql=query)
|
||||
|
||||
def create_tables():
|
||||
q(
|
||||
ch1,
|
||||
"CREATE TABLE mt ( A Int64, D Date, S String ) ENGINE MergeTree() PARTITION BY toYYYYMM(D) ORDER BY A;",
|
||||
)
|
||||
|
||||
def check_tables():
|
||||
# Check tables exists
|
||||
assert (
|
||||
q(
|
||||
ch1,
|
||||
"SHOW TABLES",
|
||||
).strip()
|
||||
== "mt"
|
||||
)
|
||||
|
||||
# Check engines
|
||||
assert (
|
||||
q(
|
||||
ch1,
|
||||
f"SELECT name, engine FROM system.tables WHERE database = '{database_name}'",
|
||||
).strip()
|
||||
== f"mt\tMergeTree"
|
||||
)
|
||||
|
||||
|
||||
def set_convert_flags():
|
||||
ch1.exec_in_container(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
f"mkdir /var/lib/clickhouse/data/{database_name}/mt/flags",
|
||||
]
|
||||
)
|
||||
ch1.exec_in_container(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
f"touch /var/lib/clickhouse/data/{database_name}/mt/flags/convert_to_replicated",
|
||||
]
|
||||
)
|
||||
|
||||
def remove_convert_flags():
|
||||
ch1.exec_in_container(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
f"rm -rf /var/lib/clickhouse/data/{database_name}/mt/flags",
|
||||
]
|
||||
)
|
||||
|
||||
def test_modify_engine_on_restart_ordinary_database(started_cluster):
|
||||
ch1.query(
|
||||
sql=f"CREATE DATABASE {database_name} ENGINE = Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
|
||||
create_tables()
|
||||
|
||||
check_tables()
|
||||
|
||||
set_convert_flags()
|
||||
|
||||
cannot_start = False
|
||||
try:
|
||||
ch1.restart_clickhouse()
|
||||
except:
|
||||
cannot_start = True
|
||||
assert cannot_start
|
||||
|
||||
remove_convert_flags()
|
||||
|
||||
ch1.restart_clickhouse()
|
||||
|
||||
check_tables()
|
Loading…
Reference in New Issue
Block a user