mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Allow start without ZooKeeper.
This commit is contained in:
parent
a70b627897
commit
14cae25bd3
@ -119,10 +119,20 @@ void UserDefinedSQLObjectsLoaderFromZooKeeper::resetAfterError()
|
||||
|
||||
void UserDefinedSQLObjectsLoaderFromZooKeeper::loadObjects()
|
||||
{
|
||||
/// loadObjects() is called at start from Server::main(), so it's better not to stop here on no connection to ZooKeeper or any other error.
|
||||
/// However the watching thread must be started anyway in case the connection will be established later.
|
||||
if (!objects_loaded)
|
||||
{
|
||||
reloadObjects();
|
||||
try
|
||||
{
|
||||
reloadObjects();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(log, "Failed to load user-defined objects");
|
||||
}
|
||||
}
|
||||
startWatchingThread();
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +85,7 @@ def test_create_and_drop():
|
||||
|
||||
def test_create_and_replace():
|
||||
node1.query("CREATE FUNCTION f1 AS (x, y) -> x + y")
|
||||
assert node1.query("SELECT f1(12, 3)") == "15\n"
|
||||
|
||||
expected_error = "User-defined function 'f1' already exists"
|
||||
assert expected_error in node1.query_and_get_error(
|
||||
@ -253,3 +254,27 @@ def test_reload_zookeeper():
|
||||
# switch to the original version of zookeeper config
|
||||
cluster.start_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
revert_zookeeper_config()
|
||||
|
||||
|
||||
# Start without ZooKeeper must be possible, user-defined functions will be loaded after connecting to ZooKeeper.
|
||||
def test_start_without_zookeeper():
|
||||
node2.stop_clickhouse()
|
||||
|
||||
node1.query("CREATE FUNCTION f1 AS (x, y) -> x + y")
|
||||
|
||||
cluster.stop_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
node2.start_clickhouse()
|
||||
|
||||
assert (
|
||||
node2.query("SELECT create_query FROM system.functions WHERE name='f1'") == ""
|
||||
)
|
||||
|
||||
cluster.start_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
wait_zookeeper_node_to_start(["zoo1", "zoo2", "zoo3"])
|
||||
|
||||
assert_eq_with_retry(
|
||||
node2,
|
||||
"SELECT create_query FROM system.functions WHERE name='f1'",
|
||||
"CREATE FUNCTION f1 AS (x, y) -> (x + y)\n",
|
||||
)
|
||||
node1.query("DROP FUNCTION f1")
|
||||
|
Loading…
Reference in New Issue
Block a user