From b1c0fe05fa76cbcd3c4e878dcece4b0eb3ce0635 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 15 Jul 2021 11:51:13 +0800 Subject: [PATCH] Fix OOM bug that SegmentBitset allocate more than the 2M size --- deps/oblib/src/lib/container/ob_2d_array.h | 2 +- src/sql/engine/aggregate/ob_exec_hash_struct.h | 2 +- src/sql/engine/ob_tenant_sql_memory_manager.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/lib/container/ob_2d_array.h b/deps/oblib/src/lib/container/ob_2d_array.h index 41610f08f3..e8abdaf8dd 100644 --- a/deps/oblib/src/lib/container/ob_2d_array.h +++ b/deps/oblib/src/lib/container/ob_2d_array.h @@ -531,7 +531,7 @@ int Ob2DArray const int64_t current_blocks = get_block_count(); for (int64_t i = current_blocks; OB_SUCC(ret) && i < need_blocks; ++i) { if (OB_FAIL(new_block())) { - LIB_LOG(WARN, "failed: new_block()", K(ret)); + LIB_LOG(WARN, "failed: new_block()", K(ret), K(need_blocks), K(capacity)); } } } diff --git a/src/sql/engine/aggregate/ob_exec_hash_struct.h b/src/sql/engine/aggregate/ob_exec_hash_struct.h index c3f5e914df..6e3c19ff6b 100644 --- a/src/sql/engine/aggregate/ob_exec_hash_struct.h +++ b/src/sql/engine/aggregate/ob_exec_hash_struct.h @@ -442,7 +442,7 @@ public: } private: - ObSegmentBitSet<> bits_; + ObSegmentBitSet bits_; int64_t cnt_; // power of 2 int64_t h2_shift_; }; diff --git a/src/sql/engine/ob_tenant_sql_memory_manager.cpp b/src/sql/engine/ob_tenant_sql_memory_manager.cpp index 5ced891a5c..0fdfbfd482 100644 --- a/src/sql/engine/ob_tenant_sql_memory_manager.cpp +++ b/src/sql/engine/ob_tenant_sql_memory_manager.cpp @@ -824,7 +824,10 @@ int ObTenantSqlMemoryManager::get_max_work_area_size(int64_t& max_wa_memory_size if (OB_FAIL(ObResourceMgr::get_instance().get_tenant_resource_mgr(tenant_id_, resource_handle))) { ret = OB_SUCCESS; } else { - max_tenant_memory_size += resource_handle.get_memory_mgr()->get_cache_hold(); + // TODO: kvcache大概可以淘汰多少内存,目前没有数据,后续寒晖他们会提供接口 + // bug34818894 https://work.aone.alibaba-inc.com/issue/34818894 + // 这里暂时写一个默认比例 + max_tenant_memory_size += resource_handle.get_memory_mgr()->get_cache_hold() * 0.05; } } int64_t remain_memory_size = -- GitLab