Merge pull request #26742 from vdimir/clickhouse-benchmark-data-race-on-cerr

Lock mutex before access to std::cerr in clickhouse-benchmark
This commit is contained in:
alexey-milovidov 2021-07-24 05:52:43 +03:00 committed by GitHub
commit ace86a7203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -271,7 +271,8 @@ private:
if (max_time > 0 && total_watch.elapsedSeconds() >= max_time) 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; return false;
} }
@ -368,8 +369,7 @@ private:
{ {
extracted = queue.tryPop(query, 100); extracted = queue.tryPop(query, 100);
if (shutdown if (shutdown || (max_iterations && queries_executed == max_iterations))
|| (max_iterations && queries_executed == max_iterations))
{ {
return; return;
} }
@ -382,8 +382,9 @@ private:
} }
catch (...) catch (...)
{ {
std::cerr << "An error occurred while processing the query '" std::lock_guard lock(mutex);
<< query << "'.\n"; std::cerr << "An error occurred while processing the query " << "'" << query << "'"
<< ": " << getCurrentExceptionMessage(false) << std::endl;
if (!continue_on_errors) if (!continue_on_errors)
{ {
shutdown = true; shutdown = true;