Fix OOM bug that SegmentBitset allocate more than the 2M size

This commit is contained in:
obdev
2021-07-15 11:51:13 +08:00
committed by wangzelin.wzl
parent 94816acd47
commit b1c0fe05fa
3 changed files with 6 additions and 3 deletions

View File

@ -531,7 +531,7 @@ int Ob2DArray<T, max_block_size, BlockAllocatorT, auto_free, BlockPointerArrayT>
const int64_t current_blocks = get_block_count(); const int64_t current_blocks = get_block_count();
for (int64_t i = current_blocks; OB_SUCC(ret) && i < need_blocks; ++i) { for (int64_t i = current_blocks; OB_SUCC(ret) && i < need_blocks; ++i) {
if (OB_FAIL(new_block())) { 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));
} }
} }
} }

View File

@ -442,7 +442,7 @@ public:
} }
private: private:
ObSegmentBitSet<> bits_; ObSegmentBitSet<common::OB_MALLOC_BIG_BLOCK_SIZE> bits_;
int64_t cnt_; // power of 2 int64_t cnt_; // power of 2
int64_t h2_shift_; int64_t h2_shift_;
}; };

View File

@ -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))) { if (OB_FAIL(ObResourceMgr::get_instance().get_tenant_resource_mgr(tenant_id_, resource_handle))) {
ret = OB_SUCCESS; ret = OB_SUCCESS;
} else { } 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 = int64_t remain_memory_size =