From 45a79bc8e8064da5f4bc2bc54d1a2ae904c62730 Mon Sep 17 00:00:00 2001 From: Minionyh Date: Wed, 26 Jul 2023 10:42:40 +0000 Subject: [PATCH] split memory to tenant --- src/storage/tx/ob_dup_table_tablets.cpp | 19 ++++++++++++------- src/storage/tx/ob_dup_table_tablets.h | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/storage/tx/ob_dup_table_tablets.cpp b/src/storage/tx/ob_dup_table_tablets.cpp index f07f6d297b..89c6953a2a 100644 --- a/src/storage/tx/ob_dup_table_tablets.cpp +++ b/src/storage/tx/ob_dup_table_tablets.cpp @@ -154,14 +154,17 @@ int ObLSDupTabletsMgr::CollectTabletsHandler::operator()( //****** DupTabletSet & DupTabletLog //********************************************************************** -int DupTabletChangeMap::create(int64_t bucket_num) +int DupTabletChangeMap::create(const uint64_t tenant_id, const int64_t bucket_num) { int ret = OB_SUCCESS; - if (!dup_set_attr_.common_header_.is_valid()) { + ObMemAttr attr(tenant_id, "DupTabletHash"); + + if (!dup_set_attr_.common_header_.is_valid() || tenant_id <= OB_INVALID_TENANT_ID) { ret = OB_ERR_UNEXPECTED; - DUP_TABLE_LOG(WARN, "invalid unique_id", K(ret), K(dup_set_attr_)); - } else if (OB_FAIL(DupTabletIdMap::create(bucket_num, "DupTabletHash"))) { - DUP_TABLE_LOG(WARN, "create dup tablet id map failed", K(ret), K(dup_set_attr_), K(bucket_num)); + DUP_TABLE_LOG(WARN, "invalid unique_id or tenant_id", K(ret), K(dup_set_attr_), K(tenant_id)); + } else if (OB_FAIL(DupTabletIdMap::create(bucket_num, attr))) { + DUP_TABLE_LOG(WARN, "create dup tablet id map failed", K(ret), K(dup_set_attr_), + K(bucket_num), K(tenant_id)); } return ret; @@ -344,6 +347,7 @@ int ObLSDupTabletsMgr::init_free_tablet_pool_() int ret = OB_SUCCESS; destroy_free_tablet_pool_(); + const uint64_t tenant_id = MTL_ID(); for (int i = 0; i < RESERVED_FREE_SET_COUNT && OB_SUCC(ret); i++) { DupTabletChangeMap *tmp_map_ptr = nullptr; @@ -352,7 +356,7 @@ int ObLSDupTabletsMgr::init_free_tablet_pool_() ret = OB_ALLOCATE_MEMORY_FAILED; // } else if (OB_FALSE_IT(extra_free_set_alloc_count_++)) { } else if (OB_FALSE_IT(new (tmp_map_ptr) DupTabletChangeMap(i + 1))) { - } else if (OB_FAIL(tmp_map_ptr->create(1024))) { + } else if (OB_FAIL(tmp_map_ptr->create(tenant_id, 1024))) { DUP_TABLE_LOG(WARN, "create dup_tablet hash map", K(ret)); } else if (false == (free_set_pool_.add_last(tmp_map_ptr))) { ret = OB_ERR_UNEXPECTED; @@ -1922,13 +1926,14 @@ int ObLSDupTabletsMgr::alloc_extra_free_tablet_set_() int ret = OB_SUCCESS; DupTabletChangeMap *tmp_map_ptr = nullptr; + const uint64_t tenant_id = MTL_ID(); if (OB_ISNULL(tmp_map_ptr = static_cast( share::mtl_malloc(sizeof(DupTabletChangeMap), "DupTabletMap")))) { ret = OB_ALLOCATE_MEMORY_FAILED; } else if (OB_FALSE_IT(extra_free_set_alloc_count_++)) { } else if (OB_FALSE_IT(new (tmp_map_ptr) DupTabletChangeMap(RESERVED_FREE_SET_COUNT + extra_free_set_alloc_count_))) { - } else if (OB_FAIL(tmp_map_ptr->create(1024))) { + } else if (OB_FAIL(tmp_map_ptr->create(tenant_id, 1024))) { DUP_TABLE_LOG(WARN, "create dup_tablet hash map", K(ret)); } else if (false == (free_set_pool_.add_last(tmp_map_ptr))) { ret = OB_ERR_UNEXPECTED; diff --git a/src/storage/tx/ob_dup_table_tablets.h b/src/storage/tx/ob_dup_table_tablets.h index 702c51338e..70b21d6030 100644 --- a/src/storage/tx/ob_dup_table_tablets.h +++ b/src/storage/tx/ob_dup_table_tablets.h @@ -361,7 +361,7 @@ public: DupTabletIdMap::destroy(); } - int create(int64_t bucket_num); + int create(const uint64_t tenant_id, const int64_t bucket_num); DupTabletSetChangeStatus *get_change_status() {