diff --git a/docker/test/integration/runner/Dockerfile b/docker/test/integration/runner/Dockerfile index 56abf1122b2..f353931f0a0 100644 --- a/docker/test/integration/runner/Dockerfile +++ b/docker/test/integration/runner/Dockerfile @@ -63,6 +63,7 @@ RUN python3 -m pip install \ cassandra-driver \ confluent-kafka \ dict2xml \ + dicttoxml \ docker \ docker-compose==1.22.0 \ grpcio \ diff --git a/docker/test/stateless/run.sh b/docker/test/stateless/run.sh index fb510a87fcd..575be721a54 100755 --- a/docker/test/stateless/run.sh +++ b/docker/test/stateless/run.sh @@ -53,10 +53,12 @@ function run_tests() if [ "$NUM_TRIES" -gt "1" ]; then ADDITIONAL_OPTIONS+=('--skip') ADDITIONAL_OPTIONS+=('00000_no_tests_to_skip') + ADDITIONAL_OPTIONS+=('--jobs') + ADDITIONAL_OPTIONS+=('4') fi clickhouse-test --testname --shard --zookeeper --hung-check --print-time \ - --test-runs "$NUM_TRIES" --jobs 4 \ + --test-runs "$NUM_TRIES" \ "$SKIP_LIST_OPT" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \ | ts '%Y-%m-%d %H:%M:%S' \ | tee -a test_output/test_result.txt diff --git a/src/Client/tests/CMakeLists.txt b/src/Client/tests/CMakeLists.txt index e69de29bb2d..d952c006bb5 100644 --- a/src/Client/tests/CMakeLists.txt +++ b/src/Client/tests/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test-connect test_connect.cpp) +target_link_libraries (test-connect PRIVATE dbms) diff --git a/src/Client/tests/test_connect.cpp b/src/Client/tests/test_connect.cpp new file mode 100644 index 00000000000..1259980f9a6 --- /dev/null +++ b/src/Client/tests/test_connect.cpp @@ -0,0 +1,99 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +/** In a loop it connects to the server and immediately breaks the connection. + * Using the SO_LINGER option, we ensure that the connection is terminated by sending a RST packet (not FIN). + * Long time ago this behavior caused a bug in the TCPServer implementation in the Poco library. + */ +int main(int argc, char ** argv) +try +{ + size_t num_iterations = 1; + size_t num_threads = 1; + std::string host = "localhost"; + uint16_t port = 9000; + + if (argc >= 2) + num_iterations = DB::parse(argv[1]); + + if (argc >= 3) + num_threads = DB::parse(argv[2]); + + if (argc >= 4) + host = argv[3]; + + if (argc >= 5) + port = DB::parse(argv[4]); + + std::atomic_bool cancel{false}; + std::vector threads(num_threads); + for (auto & thread : threads) + { + thread = std::thread([&] + { + for (size_t i = 0; i < num_iterations && !cancel.load(std::memory_order_relaxed); ++i) + { + std::cerr << "."; + + Poco::Net::SocketAddress address(host, port); + + int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP); + + if (fd < 0) + DB::throwFromErrno("Cannot create socket", 0); + + linger linger_value; + linger_value.l_onoff = 1; + linger_value.l_linger = 0; + + if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_value, sizeof(linger_value))) + DB::throwFromErrno("Cannot set linger", 0); + + try + { + Stopwatch watch; + + int res = connect(fd, address.addr(), address.length()); + + if (res != 0 && errno != EINPROGRESS && errno != EWOULDBLOCK) + { + close(fd); + DB::throwFromErrno("Cannot connect", 0); + } + + close(fd); + + if (watch.elapsedSeconds() > 0.1) + { + std::cerr << watch.elapsedSeconds() << "\n"; + cancel = true; + break; + } + } + catch (const Poco::Exception & e) + { + std::cerr << e.displayText() << "\n"; + } + } + }); + } + + for (auto & thread : threads) + thread.join(); + + std::cerr << "\n"; +} +catch (const Poco::Exception & e) +{ + std::cerr << e.displayText() << "\n"; +} diff --git a/src/Core/MySQL/MySQLClient.cpp b/src/Core/MySQL/MySQLClient.cpp index f65fbe62274..e41b4128738 100644 --- a/src/Core/MySQL/MySQLClient.cpp +++ b/src/Core/MySQL/MySQLClient.cpp @@ -6,8 +6,10 @@ #include #include #include +#include #include + namespace DB { using namespace Generic; diff --git a/src/Core/MySQL/MySQLClient.h b/src/Core/MySQL/MySQLClient.h index 5835e980149..e503c985584 100644 --- a/src/Core/MySQL/MySQLClient.h +++ b/src/Core/MySQL/MySQLClient.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Dictionaries/XDBCDictionarySource.cpp b/src/Dictionaries/XDBCDictionarySource.cpp index aa27f4efc25..3615f72605f 100644 --- a/src/Dictionaries/XDBCDictionarySource.cpp +++ b/src/Dictionaries/XDBCDictionarySource.cpp @@ -21,7 +21,7 @@ #include "registerDictionaries.h" #if USE_ODBC -# include +# include // Y_IGNORE #endif namespace DB diff --git a/src/Dictionaries/ya.make b/src/Dictionaries/ya.make index f754f250b38..4f33dc80559 100644 --- a/src/Dictionaries/ya.make +++ b/src/Dictionaries/ya.make @@ -6,12 +6,15 @@ LIBRARY() PEERDIR( clickhouse/src/Common contrib/libs/poco/Data - contrib/libs/poco/Data/ODBC contrib/libs/poco/MongoDB contrib/libs/poco/Redis contrib/libs/sparsehash ) +IF (USE_ODBC) + PEERDIR(contrib/libs/poco/Data/ODBC) +ENDIF () + NO_COMPILER_WARNINGS() diff --git a/src/Dictionaries/ya.make.in b/src/Dictionaries/ya.make.in index 5df5803e7f4..e52b106d034 100644 --- a/src/Dictionaries/ya.make.in +++ b/src/Dictionaries/ya.make.in @@ -5,12 +5,15 @@ LIBRARY() PEERDIR( clickhouse/src/Common contrib/libs/poco/Data - contrib/libs/poco/Data/ODBC contrib/libs/poco/MongoDB contrib/libs/poco/Redis contrib/libs/sparsehash ) +IF (USE_ODBC) + PEERDIR(contrib/libs/poco/Data/ODBC) +ENDIF () + NO_COMPILER_WARNINGS() diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index fc8d8654573..77f4bc976cd 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 020e5af365a..50e891a3524 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -51,7 +51,6 @@ #include #include -#include #include #include diff --git a/src/Storages/System/StorageSystemClusters.cpp b/src/Storages/System/StorageSystemClusters.cpp index 83d165f54f7..ae8bcca2804 100644 --- a/src/Storages/System/StorageSystemClusters.cpp +++ b/src/Storages/System/StorageSystemClusters.cpp @@ -1,4 +1,3 @@ -#include #include #include #include