From d1106b325e6b1baa2eb1715f9b3e5a6b252afa10 Mon Sep 17 00:00:00 2001 From: vdimir Date: Fri, 23 Jul 2021 17:35:22 +0300 Subject: [PATCH 1/2] Lock mutex before access to std::cerr in clickhouse-benchmark --- programs/benchmark/Benchmark.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp index 859222c236e..d9a9629cb07 100644 --- a/programs/benchmark/Benchmark.cpp +++ b/programs/benchmark/Benchmark.cpp @@ -271,7 +271,8 @@ private: if (max_time > 0 && total_watch.elapsedSeconds() >= max_time) { - std::cout << "Stopping launch of queries. Requested time limit is exhausted.\n"; + std::cout << "Stopping launch of queries." + << " Requested time limit " << max_time << " seconds is exhausted.\n"; return false; } @@ -368,8 +369,7 @@ private: { extracted = queue.tryPop(query, 100); - if (shutdown - || (max_iterations && queries_executed == max_iterations)) + if (shutdown || (max_iterations && queries_executed == max_iterations)) { return; } @@ -382,6 +382,7 @@ private: } catch (...) { + std::lock_guard lock(mutex); std::cerr << "An error occurred while processing the query '" << query << "'.\n"; if (!continue_on_errors) From e4f3b9e7f4e93f5653d687370030716e064bc405 Mon Sep 17 00:00:00 2001 From: vdimir Date: Fri, 23 Jul 2021 17:41:32 +0300 Subject: [PATCH 2/2] Log exception message in void thread in clickhouse-benchmark --- programs/benchmark/Benchmark.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp index d9a9629cb07..f0c1c239a6e 100644 --- a/programs/benchmark/Benchmark.cpp +++ b/programs/benchmark/Benchmark.cpp @@ -383,8 +383,8 @@ private: catch (...) { std::lock_guard lock(mutex); - std::cerr << "An error occurred while processing the query '" - << query << "'.\n"; + std::cerr << "An error occurred while processing the query " << "'" << query << "'" + << ": " << getCurrentExceptionMessage(false) << std::endl; if (!continue_on_errors) { shutdown = true;