You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/05/27 15:08:45 UTC

[incubator-doris] 02/08: [bugfix]teach BufferedBlockMgr2 track memory right (#9722)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 0dce0ff70c3f4350a0419ac1c609e4a9db0e3242
Author: Yongqiang YANG <98...@users.noreply.github.com>
AuthorDate: Tue May 24 10:18:51 2022 +0800

    [bugfix]teach BufferedBlockMgr2 track memory right (#9722)
    
    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 92edcdcabe..64db5222e1 100644
--- a/be/src/runtime/buffered_block_mgr2.cc
+++ b/be/src/runtime/buffered_block_mgr2.cc
@@ -324,9 +324,7 @@ bool BufferedBlockMgr2::consume_memory(Client* client, int64_t size) {
     }
     int buffers_needed = BitUtil::ceil(size, max_block_size());
     unique_lock<mutex> lock(_lock);
-    Status st = _mem_tracker->TryConsume(size);
-    WARN_IF_ERROR(st, "consume failed");
-    if (size < max_block_size() && st) {
+    if (size < max_block_size() && _mem_tracker->TryConsume(size)) {
         // For small allocations (less than a block size), just let the allocation through.
         client->_tracker->ConsumeLocal(size, client->_query_tracker.get());
         // client->_tracker->Consume(size);
@@ -336,7 +334,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->TryConsume(size);
+    Status st = _mem_tracker->TryConsume(size);
     WARN_IF_ERROR(st, "consume failed");
     if (st) {
         // There was still unallocated memory, don't need to recycle allocated blocks.
@@ -1094,10 +1092,9 @@ Status BufferedBlockMgr2::find_buffer_for_block(Block* block, bool* in_mem) {
 Status BufferedBlockMgr2::find_buffer(unique_lock<mutex>& lock, BufferDescriptor** buffer_desc) {
     *buffer_desc = nullptr;
 
-    Status st = _mem_tracker->TryConsume(_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->TryConsume(_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 =


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org