Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flacky test 01017_uniqCombined_memory_usage #9667

Merged
merged 1 commit into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dbms/src/Common/MemoryTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@ namespace CurrentMemoryTracker
}


/// Holding this object will temporarily disable memory tracking.
DB::SimpleActionLock getCurrentMemoryTrackerActionLock();
9 changes: 7 additions & 2 deletions dbms/src/Interpreters/SystemLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ SystemLog<LogElement>::SystemLog(Context & context_,
template <typename LogElement>
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);

if (is_shutdown)
Expand All @@ -197,9 +203,8 @@ void SystemLog<LogElement>::add(const LogElement & element)
// count increases past half available size.
const uint64_t queue_end = queue_front_index + queue.size();
if (requested_flush_before < queue_end)
{
requested_flush_before = queue_end;
}

flush_event.notify_all();
LOG_INFO(log, "Queue is half full for system log '" + demangle(typeid(*this).name()) + "'.");
}
Expand Down