Revert "Add test for #13398"

This commit is contained in:
tavplubix 2021-08-27 21:07:10 +03:00 committed by GitHub
parent fde3cc1315
commit c36fe210b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 13 additions and 55 deletions

View File

@ -80,9 +80,7 @@ PoolWithFailover::PoolWithFailover(
const std::string & password,
unsigned default_connections_,
unsigned max_connections_,
size_t max_tries_,
size_t connect_timeout,
size_t rw_timeout)
size_t max_tries_)
: max_tries(max_tries_)
, shareable(false)
{
@ -92,8 +90,8 @@ PoolWithFailover::PoolWithFailover(
replicas_by_priority[0].emplace_back(std::make_shared<Pool>(database,
host, user, password, port,
/* socket_ = */ "",
connect_timeout,
rw_timeout,
MYSQLXX_DEFAULT_TIMEOUT,
MYSQLXX_DEFAULT_RW_TIMEOUT,
default_connections_,
max_connections_));
}
@ -132,6 +130,7 @@ PoolWithFailover::Entry PoolWithFailover::get()
for (size_t try_no = 0; try_no < max_tries; ++try_no)
{
full_pool = nullptr;
for (auto & priority_replicas : replicas_by_priority)
{
Replicas & replicas = priority_replicas.second;

View File

@ -117,9 +117,7 @@ namespace mysqlxx
const std::string & password,
unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES,
size_t connect_timeout = MYSQLXX_DEFAULT_TIMEOUT,
size_t rw_timeout = MYSQLXX_DEFAULT_RW_TIMEOUT);
size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES);
PoolWithFailover(const PoolWithFailover & other);

View File

@ -482,8 +482,6 @@ class IColumn;
M(UInt64, distributed_ddl_entry_format_version, 1, "Version of DDL entry to write into ZooKeeper", 0) \
M(UInt64, external_storage_max_read_rows, 0, "Limit maximum number of rows when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, dictionary and MaterializedMySQL. If equal to 0, this setting is disabled", 0) \
M(UInt64, external_storage_max_read_bytes, 0, "Limit maximum number of bytes when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, dictionary and MaterializedMySQL. If equal to 0, this setting is disabled", 0) \
M(UInt64, external_storage_connect_timeout, 100, "Connect timeout for external database (Now supported for MySQL)", 0) \
M(UInt64, external_storage_rw_timeout, 1800, "Read / write timeout for external database (Now supported for MySQL)", 0) \
M(UnionMode, union_default_mode, UnionMode::Unspecified, "Set default Union Mode in SelectWithUnion query. Possible values: empty string, 'ALL', 'DISTINCT'. If empty, query without Union Mode will throw exception.", 0) \
M(Bool, optimize_aggregators_of_group_by_keys, true, "Eliminates min/max/any/anyLast aggregators of GROUP BY keys in SELECT section", 0) \
M(Bool, optimize_group_by_function_keys, true, "Eliminates functions of other keys in GROUP BY section", 0) \

View File

@ -155,13 +155,7 @@ DatabasePtr DatabaseFactory::getImpl(const ASTCreateQuery & create, const String
/// Split into replicas if needed.
size_t max_addresses = context->getSettingsRef().glob_expansion_max_elements;
auto addresses = parseRemoteDescriptionForExternalDatabase(host_port, max_addresses, 3306);
mysqlxx::PoolWithFailover mysql_pool(mysql_database_name, addresses,
mysql_user_name, mysql_user_password,
MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES,
context->getSettingsRef().external_storage_connect_timeout,
context->getSettingsRef().external_storage_rw_timeout);
auto mysql_pool = mysqlxx::PoolWithFailover(mysql_database_name, addresses, mysql_user_name, mysql_user_password);
mysql_database_settings->loadFromQueryContext(context);
mysql_database_settings->loadFromQuery(*engine_define); /// higher priority
@ -174,6 +168,7 @@ DatabasePtr DatabaseFactory::getImpl(const ASTCreateQuery & create, const String
MySQLClient client(remote_host_name, remote_port, mysql_user_name, mysql_user_password);
auto mysql_pool = mysqlxx::Pool(mysql_database_name, remote_host_name, mysql_user_name, mysql_user_password, remote_port);
auto materialize_mode_settings = std::make_unique<MaterializedMySQLSettings>();
if (engine_define->settings)

View File

@ -271,9 +271,7 @@ void registerStorageMySQL(StorageFactory & factory)
username, password,
MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
mysql_settings.connection_pool_size,
mysql_settings.connection_max_tries,
args.getContext()->getSettingsRef().external_storage_connect_timeout,
args.getContext()->getSettingsRef().external_storage_rw_timeout);
mysql_settings.connection_max_tries);
bool replace_query = false;
std::string on_duplicate_clause;

View File

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<yandex>
<profiles>
<default>
<external_storage_connect_timeout>3</external_storage_connect_timeout>
<external_storage_rw_timeout>3</external_storage_rw_timeout>
</default>
</profiles>
</yandex>

25
tests/integration/test_mysql_database_engine/test.py Executable file → Normal file
View File

@ -8,7 +8,7 @@ from helpers.client import QueryRuntimeException
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
clickhouse_node = cluster.add_instance('node1', main_configs=['configs/remote_servers.xml'], user_configs=['configs/users.xml'], with_mysql=True)
clickhouse_node = cluster.add_instance('node1', main_configs=['configs/remote_servers.xml'], with_mysql=True)
@pytest.fixture(scope="module")
@ -404,26 +404,3 @@ def test_mysql_types(started_cluster, case_name, mysql_type, expected_ch_type, m
execute_query(clickhouse_node,
"SELECT value FROM mysql('mysql57:3306', '${mysql_db}', '${table_name}', 'root', 'clickhouse')",
settings=clickhouse_query_settings)
def test_clickhouse_mysql_no_connection(started_cluster):
with contextlib.closing(MySQLNodeInstance('root', 'clickhouse', started_cluster.mysql_ip, started_cluster.mysql_port)) as mysql_node:
mysql_node.query("CREATE DATABASE test_database DEFAULT CHARACTER SET 'utf8'")
mysql_node.query('CREATE TABLE `test_database`.`test_table` ( `i``d` int(11) NOT NULL, PRIMARY KEY (`i``d`)) ENGINE=InnoDB;')
clickhouse_node.query("CREATE DATABASE test_database ENGINE = MySQL('mysql57:3306', test_database, 'root', 'clickhouse')")
clickhouse_node.query("INSERT INTO `test_database`.`test_table`(`i``d`) select number from numbers(10000)")
assert clickhouse_node.query("SELECT count() FROM `test_database`.`test_table`").rstrip() == '10000'
started_cluster.pause_container('mysql57');
result = clickhouse_node.query_and_get_error("SELECT count() FROM `test_database`.`test_table`")
assert('Exception: Connections to all replicas failed' in result)
started_cluster.unpause_container('mysql57');
result = clickhouse_node.query("SELECT count() FROM `test_database`.`test_table`")
assert(result.strip() == '10000')
started_cluster.pause_container('mysql57');
clickhouse_node.query("DROP DATABASE test_database")
assert 'test_database' not in clickhouse_node.query('SHOW DATABASES')
started_cluster.unpause_container('mysql57');

View File

@ -1,3 +1,5 @@
send_timeout Seconds 300
function_range_max_elements_in_block UInt64 500000000
connect_timeout Seconds 10
connect_timeout_with_failover_ms Milliseconds 2000
connect_timeout_with_failover_secure_ms Milliseconds 3000
max_memory_usage UInt64 10000000000

View File

@ -1,3 +1,3 @@
show settings like 'send_timeout';
SHOW SETTINGS ILIKE '%RANGE_max%';
SHOW SETTINGS ILIKE '%CONNECT_timeout%';
SHOW CHANGED SETTINGS ILIKE '%MEMORY%';