From c36fe210b8beaa32b07b5b388a464ec02aca97b6 Mon Sep 17 00:00:00 2001 From: tavplubix Date: Fri, 27 Aug 2021 21:07:10 +0300 Subject: [PATCH] Revert "Add test for #13398" --- base/mysqlxx/PoolWithFailover.cpp | 9 +++---- base/mysqlxx/PoolWithFailover.h | 4 +-- src/Core/Settings.h | 2 -- src/Databases/DatabaseFactory.cpp | 9 ++----- src/Storages/StorageMySQL.cpp | 4 +-- .../configs/users.xml | 9 ------- .../test_mysql_database_engine/test.py | 25 +------------------ .../0_stateless/01293_show_settings.reference | 4 ++- .../0_stateless/01293_show_settings.sql | 2 +- 9 files changed, 13 insertions(+), 55 deletions(-) delete mode 100644 tests/integration/test_mysql_database_engine/configs/users.xml mode change 100755 => 100644 tests/integration/test_mysql_database_engine/test.py diff --git a/base/mysqlxx/PoolWithFailover.cpp b/base/mysqlxx/PoolWithFailover.cpp index f449708dc46..e317ab7f228 100644 --- a/base/mysqlxx/PoolWithFailover.cpp +++ b/base/mysqlxx/PoolWithFailover.cpp @@ -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(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; diff --git a/base/mysqlxx/PoolWithFailover.h b/base/mysqlxx/PoolWithFailover.h index e3c5ebe76e1..1c7a63e76c0 100644 --- a/base/mysqlxx/PoolWithFailover.h +++ b/base/mysqlxx/PoolWithFailover.h @@ -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); diff --git a/src/Core/Settings.h b/src/Core/Settings.h index 3d52f0d3bd5..74600bd5095 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -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) \ diff --git a/src/Databases/DatabaseFactory.cpp b/src/Databases/DatabaseFactory.cpp index 01bc8cb34c7..75a3b9c9e1e 100644 --- a/src/Databases/DatabaseFactory.cpp +++ b/src/Databases/DatabaseFactory.cpp @@ -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(); if (engine_define->settings) diff --git a/src/Storages/StorageMySQL.cpp b/src/Storages/StorageMySQL.cpp index ee5bd1eb03d..79bb1f59cc7 100644 --- a/src/Storages/StorageMySQL.cpp +++ b/src/Storages/StorageMySQL.cpp @@ -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; diff --git a/tests/integration/test_mysql_database_engine/configs/users.xml b/tests/integration/test_mysql_database_engine/configs/users.xml deleted file mode 100644 index 12c6d97d4eb..00000000000 --- a/tests/integration/test_mysql_database_engine/configs/users.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - 3 - 3 - - - diff --git a/tests/integration/test_mysql_database_engine/test.py b/tests/integration/test_mysql_database_engine/test.py old mode 100755 new mode 100644 index 4a826213594..a093c2a0125 --- a/tests/integration/test_mysql_database_engine/test.py +++ b/tests/integration/test_mysql_database_engine/test.py @@ -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'); diff --git a/tests/queries/0_stateless/01293_show_settings.reference b/tests/queries/0_stateless/01293_show_settings.reference index 5079f5c3d00..6fcbf194614 100644 --- a/tests/queries/0_stateless/01293_show_settings.reference +++ b/tests/queries/0_stateless/01293_show_settings.reference @@ -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 diff --git a/tests/queries/0_stateless/01293_show_settings.sql b/tests/queries/0_stateless/01293_show_settings.sql index abdb06ff05e..08f00ed201c 100644 --- a/tests/queries/0_stateless/01293_show_settings.sql +++ b/tests/queries/0_stateless/01293_show_settings.sql @@ -1,3 +1,3 @@ show settings like 'send_timeout'; -SHOW SETTINGS ILIKE '%RANGE_max%'; +SHOW SETTINGS ILIKE '%CONNECT_timeout%'; SHOW CHANGED SETTINGS ILIKE '%MEMORY%';