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

zouxinyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 06451c4ff1 fix: infinit loop when handle exceed limit memory (#21556)
06451c4ff1 is described below

commit 06451c4ff1fca64ff3f310151a3aae1b7ade2d55
Author: shuke <37901441+shuke...@users.noreply.github.com>
AuthorDate: Thu Jul 6 14:34:29 2023 +0800

    fix: infinit loop when handle exceed limit memory (#21556)
    
    In some situation, _handle_mem_exceed_limit will alloc a large memory 
block, more than 5G. After add some log, we found that:
    
    alloc memory was made in vector::insert_realloc
    writers_to_reduce_mem's size is more than 8 million.
    which indicated that an infinite loop was met in while 
(!tablets_mem_heap.empty()).
    By reviewing codes, """ if (std::get<0>(tablet_mem_item)++ != 
std::get<1>(tablet_mem_item)) """ is wrong,
    which must be """ if (++std::get<0>(tablet_mem_item) != 
std::get<1>(tablet_mem_item)) """.
    In the original code, we will made ++ on end iterator, and then compare to 
end iterator, the behavior is undefined.
---
 be/src/runtime/load_channel_mgr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/be/src/runtime/load_channel_mgr.cpp 
b/be/src/runtime/load_channel_mgr.cpp
index e0c5a6848e..2a0020a9ff 100644
--- a/be/src/runtime/load_channel_mgr.cpp
+++ b/be/src/runtime/load_channel_mgr.cpp
@@ -394,7 +394,7 @@ void LoadChannelMgr::_handle_mem_exceed_limit() {
                 break;
             }
             tablets_mem_heap.pop();
-            if (std::get<0>(tablet_mem_item)++ != 
std::get<1>(tablet_mem_item)) {
+            if (++std::get<0>(tablet_mem_item) != 
std::get<1>(tablet_mem_item)) {
                 tablets_mem_heap.push(tablet_mem_item);
             }
         }


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

Reply via email to