| 58 | } |
| 59 | |
| 60 | void CgroupsMemoryUsageObserver::runThread() |
| 61 | { |
| 62 | DB::setThreadName(DB::ThreadName::CGROUP_MEMORY_OBSERVER); |
| 63 | |
| 64 | last_available_memory_amount = getMemoryAmount(); |
| 65 | LOG_INFO(log, "Memory amount initially available to the process is {}", ReadableSize(last_available_memory_amount)); |
| 66 | |
| 67 | std::unique_lock lock(thread_mutex); |
| 68 | while (true) |
| 69 | { |
| 70 | if (cond.wait_for(lock, wait_time, [this] { return quit; })) |
| 71 | break; |
| 72 | |
| 73 | try |
| 74 | { |
| 75 | uint64_t available_memory_amount = getMemoryAmount(); |
| 76 | if (available_memory_amount != last_available_memory_amount) |
| 77 | { |
| 78 | LOG_INFO(log, "Memory amount available to the process changed from {} to {}", ReadableSize(last_available_memory_amount), ReadableSize(available_memory_amount)); |
| 79 | last_available_memory_amount = available_memory_amount; |
| 80 | std::lock_guard<std::mutex> memory_amount_available_changed_lock(memory_amount_available_changed_mutex); |
| 81 | on_memory_amount_available_changed(); |
| 82 | } |
| 83 | } |
| 84 | catch (...) |
| 85 | { |
| 86 | tryLogCurrentException(log, __PRETTY_FUNCTION__); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | } |
| 92 |
nothing calls this directly
no test coverage detected