Merge pull request #58051 from ClickHouse/tavplubix-patch-10

Small improvement for SystemLogBase
This commit is contained in:
Alexander Tokmakov 2023-12-22 20:24:08 +01:00 committed by GitHub
commit 499984e57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,6 +188,9 @@ typename SystemLogQueue<LogElement>::Index SystemLogQueue<LogElement>::pop(std::
bool & should_prepare_tables_anyway,
bool & exit_this_thread)
{
/// Call dtors and deallocate strings without holding the global lock
output.resize(0);
std::unique_lock lock(mutex);
flush_event.wait_for(lock,
std::chrono::milliseconds(settings.flush_interval_milliseconds),
@ -200,7 +203,6 @@ typename SystemLogQueue<LogElement>::Index SystemLogQueue<LogElement>::pop(std::
queue_front_index += queue.size();
// Swap with existing array from previous flush, to save memory
// allocations.
output.resize(0);
queue.swap(output);
should_prepare_tables_anyway = is_force_prepare_tables;