diff --git a/mittest/mtlenv/storage/test_ls_tablet_service.cpp b/mittest/mtlenv/storage/test_ls_tablet_service.cpp index c16384ac65..00c96f21f0 100644 --- a/mittest/mtlenv/storage/test_ls_tablet_service.cpp +++ b/mittest/mtlenv/storage/test_ls_tablet_service.cpp @@ -182,6 +182,19 @@ void TestLSTabletService::construct_and_get_tablet_list( tablet_handle_head.get_obj()->set_next_tablet_guard(tablet_handle_tail); } +TEST_F(TestLSTabletService, test_bucket_cnt) +{ + const int64_t unify_bucket_num = common::hash::cal_next_prime(ObTabletCommon::BUCKET_LOCK_BUCKET_CNT); + const int64_t lock_bkt_cnt = ls_tablet_service_->bucket_lock_.bucket_cnt_; + const int64_t id_set_lock_bkt_cnt = ls_tablet_service_->tablet_id_set_.bucket_lock_.bucket_cnt_; + const int64_t id_set_bkt_cnt = ls_tablet_service_->tablet_id_set_.id_set_.ht_.get_bucket_count(); + + ASSERT_NE(unify_bucket_num, 0); + // ASSERT_EQ(unify_bucket_num, lock_bkt_cnt); + ASSERT_EQ(unify_bucket_num, id_set_lock_bkt_cnt); + ASSERT_EQ(unify_bucket_num, id_set_bkt_cnt); +} + TEST_F(TestLSTabletService, test_create_tablet_without_index) { int ret = OB_SUCCESS; diff --git a/mittest/mtlenv/storage/test_tenant_meta_mem_mgr.cpp b/mittest/mtlenv/storage/test_tenant_meta_mem_mgr.cpp index e68b93e12a..731c0fed2f 100644 --- a/mittest/mtlenv/storage/test_tenant_meta_mem_mgr.cpp +++ b/mittest/mtlenv/storage/test_tenant_meta_mem_mgr.cpp @@ -279,6 +279,25 @@ void TestConcurrentT3M::run1() } } +TEST_F(TestTenantMetaMemMgr, test_bucket_cnt) +{ + const int64_t unify_bucket_num = common::hash::cal_next_prime(t3m_.cal_adaptive_bucket_num()); + const int64_t t3m_lock_bkt_cnt = t3m_.bucket_lock_.bucket_cnt_; + const int64_t t3m_map_bkt_cnt = t3m_.tablet_map_.map_.bucket_count(); + const int64_t t3m_map_lock_bkt_cnt = t3m_.tablet_map_.bucket_lock_.bucket_cnt_; + ASSERT_NE(unify_bucket_num, 0); + // ASSERT_EQ(unify_bucket_num, t3m_lock_bkt_cnt); + ASSERT_EQ(unify_bucket_num, t3m_map_bkt_cnt); + ASSERT_EQ(unify_bucket_num, t3m_map_lock_bkt_cnt); + + const int64_t unify_pin_set_bkt_cnt = common::hash::cal_next_prime(ObTenantMetaMemMgr::DEFAULT_BUCKET_NUM); + const int64_t pin_set_lock_bkt_cnt = t3m_.pin_set_lock_.bucket_cnt_; + const int64_t pin_set_bkt_cnt = t3m_.pinned_tablet_set_.ht_.get_bucket_count(); + ASSERT_NE(unify_pin_set_bkt_cnt, 0); + ASSERT_EQ(unify_pin_set_bkt_cnt, pin_set_lock_bkt_cnt); + ASSERT_EQ(unify_pin_set_bkt_cnt, pin_set_bkt_cnt); +} + TEST_F(TestTenantMetaMemMgr, test_sstable) { int ret = OB_SUCCESS; diff --git a/src/storage/meta_mem/ob_tenant_meta_mem_mgr.cpp b/src/storage/meta_mem/ob_tenant_meta_mem_mgr.cpp index 0cc2d03b67..70875497ce 100644 --- a/src/storage/meta_mem/ob_tenant_meta_mem_mgr.cpp +++ b/src/storage/meta_mem/ob_tenant_meta_mem_mgr.cpp @@ -136,6 +136,7 @@ int ObTenantMetaMemMgr::init() int ret = OB_SUCCESS; lib::ObMemAttr mem_attr(tenant_id_, "MetaAllocator", ObCtxIds::META_OBJ_CTX_ID); const int64_t bucket_num = cal_adaptive_bucket_num(); + const int64_t pin_set_bucket_num = common::hash::cal_next_prime(DEFAULT_BUCKET_NUM); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("ObTenantMetaMemMgr has been initialized", K(ret)); @@ -150,10 +151,10 @@ int ObTenantMetaMemMgr::init() LOG_WARN("fail to initialize tablet map", K(ret), K(bucket_num)); } else if (OB_FAIL(last_min_minor_sstable_set_.create(DEFAULT_MINOR_SSTABLE_SET_COUNT))) { LOG_WARN("fail to create last min minor sstable set", K(ret)); - } else if (OB_FAIL(pin_set_lock_.init(DEFAULT_BUCKET_NUM, ObLatchIds::BLOCK_MANAGER_LOCK, "T3MPinLock", + } else if (OB_FAIL(pin_set_lock_.init(pin_set_bucket_num, ObLatchIds::BLOCK_MANAGER_LOCK, "T3MPinLock", tenant_id_))) { LOG_WARN("fail to init pin set lock", K(ret)); - } else if (OB_FAIL(pinned_tablet_set_.create(DEFAULT_BUCKET_NUM))) { + } else if (OB_FAIL(pinned_tablet_set_.create(pin_set_bucket_num))) { LOG_WARN("fail to create pinned tablet set", K(ret)); } else if (OB_FAIL(TG_CREATE_TENANT(lib::TGDefIDs::TenantMetaMemMgr, tg_id_))) { LOG_WARN("fail to create thread for t3m", K(ret));