This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit acb37a13fbb39b7382235c3c14ac23d9eb895739 Author: shuke <[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
