diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 2b4eee74386..d4f830e5a0c 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -477,13 +477,6 @@ int Server::main(const std::vector & /*args*/) CurrentMetrics::set(CurrentMetrics::Revision, ClickHouseRevision::getVersionRevision()); CurrentMetrics::set(CurrentMetrics::VersionInteger, ClickHouseRevision::getVersionInteger()); - if (ThreadFuzzer::instance().isEffective()) - LOG_WARNING(log, "ThreadFuzzer is enabled. Application will run slowly and unstable."); - -#if defined(SANITIZER) - LOG_WARNING(log, "Server was built with sanitizer. It will work slowly."); -#endif - /** Context contains all that query execution is dependent: * settings, available functions, data types, aggregate functions, databases, ... */ @@ -497,6 +490,14 @@ int Server::main(const std::vector & /*args*/) global_context->addWarningMessage("Server was built in debug mode. It will work slowly."); #endif +if (ThreadFuzzer::instance().isEffective()) + global_context->addWarningMessage("ThreadFuzzer is enabled. Application will run slowly and unstable."); + +#if defined(SANITIZER) + global_context->addWarningMessage("Server was built with sanitizer. It will work slowly."); +#endif + + // Initialize global thread pool. Do it before we fetch configs from zookeeper // nodes (`from_zk`), because ZooKeeper interface uses the pool. We will // ignore `max_thread_pool_size` in configs we fetch from ZK, but oh well. @@ -552,8 +553,10 @@ int Server::main(const std::vector & /*args*/) if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1) { /// Program is run under debugger. Modification of it's binary image is ok for breakpoints. - LOG_WARNING(log, "Server is run under debugger and its binary image is modified (most likely with breakpoints).", - calculated_binary_hash); + global_context->addWarningMessage( + fmt::format("Server is run under debugger and its binary image is modified (most likely with breakpoints).", + calculated_binary_hash) + ); } else { @@ -636,7 +639,7 @@ int Server::main(const std::vector & /*args*/) } else { - LOG_WARNING(log, message); + global_context->addWarningMessage(message); } } diff --git a/src/Storages/System/StorageSystemWarnings.cpp b/src/Storages/System/StorageSystemWarnings.cpp index 6d9bc20cb43..55005736890 100644 --- a/src/Storages/System/StorageSystemWarnings.cpp +++ b/src/Storages/System/StorageSystemWarnings.cpp @@ -15,7 +15,7 @@ NamesAndTypesList StorageSystemWarnings::getNamesAndTypes() void StorageSystemWarnings::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { for (auto& warning : context->getWarnings()) { - res_columns[0]->insert("Warning: " + warning); + res_columns[0]->insert(warning); } } diff --git a/tests/queries/0_stateless/01941_system_warnings.expect b/tests/queries/0_stateless/01941_system_warnings.expect new file mode 100755 index 00000000000..fec6d43867e --- /dev/null +++ b/tests/queries/0_stateless/01941_system_warnings.expect @@ -0,0 +1,34 @@ +#!/usr/bin/expect -f + +# This is a test for system.warnings. Testing in interactive mode is necessary, +# as we want to see certain warnings from client + +log_user 0 +set timeout 60 +match_max 100000 + +# A default timeout action is to do nothing, change it to fail +expect_after { + timeout { + exit 1 + } +} + +set basedir [file dirname $argv0] +spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT --disable_suggestion" +expect ":) " + + +send -- "SELECT value FROM system.build_options WHERE name='BUILD_TYPE'" +expect { + "Debug" { + send -- "SELECT message FROM system.warnings WHERE message='Server was built in debug mode. It will work slowly.'" + expect "Server was built in debug mode. It will work slowly." + puts 2 + } + "RelWithDebInfo" +} + +# Finish test +send -- "\4" +expect eof \ No newline at end of file diff --git a/tests/queries/0_stateless/01941_system_warnings.reference b/tests/queries/0_stateless/01941_system_warnings.reference new file mode 100644 index 00000000000..e69de29bb2d