diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.cpp b/dbms/src/Interpreters/ExpressionAnalyzer.cpp index c2c61297ade..b8e5201525e 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.cpp +++ b/dbms/src/Interpreters/ExpressionAnalyzer.cpp @@ -697,6 +697,17 @@ void ExpressionAnalyzer::makeExplicitSet(ASTFunction * node, const Block & sampl if (left_arg_tuple && left_arg_tuple->name == "tuple") { + for (const auto & arg : left_arg_tuple->arguments->children) + { + const auto & data_type = sample_block.getByName(arg->getColumnName()).type; + + /// @note prevent crash in query: SELECT (1, [1]) in (1, 1) + if (const auto array = typeid_cast(data_type.get())) + throw Exception("Incorrect element of tuple: " + array->getName(), ErrorCodes::INCORRECT_ELEMENT_OF_SET); + + set_element_types.push_back(data_type); + } + for (ASTs::const_iterator it = left_arg_tuple->arguments->children.begin(); it != left_arg_tuple->arguments->children.end(); ++it) diff --git a/libs/libzkutil/src/ZooKeeper.cpp b/libs/libzkutil/src/ZooKeeper.cpp index 7ca889c3bc3..844d11b4410 100644 --- a/libs/libzkutil/src/ZooKeeper.cpp +++ b/libs/libzkutil/src/ZooKeeper.cpp @@ -90,14 +90,15 @@ struct ZooKeeperArgs config.keys(config_name, keys); std::string node_key = "node"; + std::vector hosts_strings; + session_timeout_ms = DEFAULT_SESSION_TIMEOUT; for (const auto & key : keys) { if (key == node_key || key.compare(0, node_key.size(), node_key) == 0) { - if (hosts.size()) - hosts += std::string(","); - hosts += config.getString(config_name + "." + key + ".host") + ":" + config.getString(config_name + "." + key + ".port"); + hosts_strings.push_back( + config.getString(config_name + "." + key + ".host") + ":" + config.getString(config_name + "." + key + ".port")); } else if (key == "session_timeout_ms") { @@ -105,6 +106,16 @@ struct ZooKeeperArgs } else throw KeeperException(std::string("Unknown key ") + key + " in config file"); } + + /// перемешиваем порядок хостов, чтобы сделать нагрузку на zookeeper более равномерной + std::random_shuffle(hosts_strings.begin(), hosts_strings.end()); + + for (auto & host : hosts_strings) + { + if (hosts.size()) + hosts += ","; + hosts += host; + } } std::string hosts;