From a8d3788e889e087881d33837d264d69a9782ff67 Mon Sep 17 00:00:00 2001 From: Yi WU Date: Sun, 22 May 2022 13:39:47 +0800 Subject: [PATCH] teach BufferedBlockMgr2 track memory right The problem was introduced by e2d3d0134eee5d50b6619fd9194a2e5f9cb557dc. --- be/src/runtime/buffered_block_mgr2.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/be/src/runtime/buffered_block_mgr2.cc b/be/src/runtime/buffered_block_mgr2.cc index 4ed5472b7ca58c..7b8a87b7624084 100644 --- a/be/src/runtime/buffered_block_mgr2.cc +++ b/be/src/runtime/buffered_block_mgr2.cc @@ -317,9 +317,7 @@ bool BufferedBlockMgr2::consume_memory(Client* client, int64_t size) { } int buffers_needed = BitUtil::ceil(size, max_block_size()); unique_lock lock(_lock); - Status st = _mem_tracker->try_consume(size); - WARN_IF_ERROR(st, "consume failed"); - if (size < max_block_size() && st) { + if (size < max_block_size() && _mem_tracker->try_consume(size)) { // For small allocations (less than a block size), just let the allocation through. client->_tracker->consume(size); return true; @@ -328,7 +326,7 @@ bool BufferedBlockMgr2::consume_memory(Client* client, int64_t size) { if (available_buffers(client) + client->_num_tmp_reserved_buffers < buffers_needed) { return false; } - st = _mem_tracker->try_consume(size); + Status st = _mem_tracker->try_consume(size); WARN_IF_ERROR(st, "consume failed"); if (st) { // There was still unallocated memory, don't need to recycle allocated blocks. @@ -1083,10 +1081,9 @@ Status BufferedBlockMgr2::find_buffer_for_block(Block* block, bool* in_mem) { Status BufferedBlockMgr2::find_buffer(unique_lock& lock, BufferDescriptor** buffer_desc) { *buffer_desc = nullptr; - Status st = _mem_tracker->try_consume(_max_block_size); - WARN_IF_ERROR(st, "try to allocate a new buffer failed"); // First, try to allocate a new buffer. - if (_free_io_buffers.size() < _block_write_threshold && st) { + if (_free_io_buffers.size() < _block_write_threshold && + _mem_tracker->try_consume(_max_block_size)) { uint8_t* new_buffer = new uint8_t[_max_block_size]; *buffer_desc = _obj_pool.add(new BufferDescriptor(new_buffer, _max_block_size)); (*buffer_desc)->all_buffers_it =