Merge pull request #9667 from ClickHouse/fix-flacky-test-uniq-combined-memory-usage

Fix flacky test 01017_uniqCombined_memory_usage
This commit is contained in:
alexey-milovidov 2020-03-15 05:40:23 +03:00 committed by GitHub
commit f3f1208e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -130,4 +130,5 @@ namespace CurrentMemoryTracker
} }
/// Holding this object will temporarily disable memory tracking.
DB::SimpleActionLock getCurrentMemoryTrackerActionLock(); DB::SimpleActionLock getCurrentMemoryTrackerActionLock();

View File

@ -182,6 +182,12 @@ SystemLog<LogElement>::SystemLog(Context & context_,
template <typename LogElement> template <typename LogElement>
void SystemLog<LogElement>::add(const LogElement & element) void SystemLog<LogElement>::add(const LogElement & element)
{ {
/// Memory can be allocated while resizing on queue.push_back.
/// The size of allocation can be in order of a few megabytes.
/// But this should not be accounted for query memory usage.
/// Otherwise the tests like 01017_uniqCombined_memory_usage.sql will be flacky.
auto temporarily_disable_memory_tracker = getCurrentMemoryTrackerActionLock();
std::unique_lock lock(mutex); std::unique_lock lock(mutex);
if (is_shutdown) if (is_shutdown)
@ -196,9 +202,8 @@ void SystemLog<LogElement>::add(const LogElement & element)
// count increases past half available size. // count increases past half available size.
const uint64_t queue_end = queue_front_index + queue.size(); const uint64_t queue_end = queue_front_index + queue.size();
if (requested_flush_before < queue_end) if (requested_flush_before < queue_end)
{
requested_flush_before = queue_end; requested_flush_before = queue_end;
}
flush_event.notify_all(); flush_event.notify_all();
LOG_INFO(log, "Queue is half full for system log '" + demangle(typeid(*this).name()) + "'."); LOG_INFO(log, "Queue is half full for system log '" + demangle(typeid(*this).name()) + "'.");
} }