[FEAT MERGE] merge transfer

Co-authored-by: wxhwang <wxhwang@126.com>
Co-authored-by: godyangfight <godyangfight@gmail.com>
Co-authored-by: Tyshawn <tuyunshan@gmail.com>
This commit is contained in:
xuhuleon
2023-06-21 11:42:26 +00:00
committed by ob-robot
parent d06678002e
commit 9dae112952
1280 changed files with 149724 additions and 48813 deletions

View File

@ -39,12 +39,11 @@ template<>
int ObMetaPointerMap<ObTabletMapKey, ObTablet>::load_meta_obj(
const ObTabletMapKey &key,
ObMetaPointer<ObTablet> *meta_pointer,
common::ObIAllocator &allocator,
common::ObArenaAllocator &allocator,
ObMetaDiskAddr &load_addr,
ObTablet *&t,
const bool using_obj_pool)
ObTablet *t)
{
UNUSEDx(key, meta_pointer, allocator, load_addr, t, using_obj_pool);
UNUSEDx(key, meta_pointer, allocator, load_addr, t);
return OB_SUCCESS;
}
@ -61,6 +60,7 @@ public:
private:
static constexpr uint64_t TEST_TENANT_ID = OB_SERVER_TENANT_ID;
ObMetaPointerMap<ObTabletMapKey, ObTablet> tablet_map_;
common::ObArenaAllocator allocator_;
ObTenantBase tenant_base_;
};
@ -105,7 +105,6 @@ void TestMetaPointerMap::FakeLs(ObLS &ls)
ls.ls_meta_.rebuild_seq_ = 0;
}
class CalculateSize final
{
public:
@ -149,8 +148,6 @@ TEST_F(TestMetaPointerMap, test_meta_pointer_handle)
ObMemtableMgrHandle memtable_mgr_hdl;
ObDDLKvMgrHandle ddl_kv_mgr_hdl;
common::ObIAllocator &allocator = MTL(ObTenantMetaMemMgr*)->get_tenant_allocator();
ret = MTL(ObTenantMetaMemMgr*)->acquire_tablet_memtable_mgr(memtable_mgr_hdl);
ASSERT_EQ(common::OB_SUCCESS, ret);
@ -216,8 +213,6 @@ TEST_F(TestMetaPointerMap, test_meta_pointer_map)
ObMemtableMgrHandle memtable_mgr_hdl;
ObDDLKvMgrHandle ddl_kv_mgr_hdl;
common::ObIAllocator &allocator = MTL(ObTenantMetaMemMgr*)->get_tenant_allocator();
ret = MTL(ObTenantMetaMemMgr*)->acquire_tablet_memtable_mgr(memtable_mgr_hdl);
ASSERT_EQ(common::OB_SUCCESS, ret);
@ -241,7 +236,7 @@ TEST_F(TestMetaPointerMap, test_meta_pointer_map)
ASSERT_EQ(1, tablet_map_.map_.size());
ObTabletHandle handle;
ret = tablet_map_.get_meta_obj(key, allocator, handle);
ret = tablet_map_.get_meta_obj(key, handle);
ASSERT_EQ(common::OB_ITEM_NOT_SETTED, ret);
ASSERT_TRUE(!handle.is_valid());
ASSERT_EQ(nullptr, handle.get_obj());
@ -251,36 +246,40 @@ TEST_F(TestMetaPointerMap, test_meta_pointer_map)
ObTablet *old_tablet = new ObTablet();
ObMetaObj<ObTablet> old_tablet_obj;
old_tablet_obj.ptr_ = old_tablet;
old_tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_pool_;
old_tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_buffer_pool_;
handle.set_obj(old_tablet_obj);
/**
ret = tablet_map_.set_meta_obj(key, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
*/
phy_addr.first_id_ = 1;
phy_addr.second_id_ = 2;
phy_addr.offset_ = 0;
phy_addr.size_ = 4096;
phy_addr.type_ = ObMetaDiskAddr::DiskType::BLOCK;
ret = tablet_map_.compare_and_swap_address_and_object(key, phy_addr, handle, handle);
ret = tablet_map_.compare_and_swap_addr_and_object(key, phy_addr, handle, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ObTablet *tablet = new ObTablet();
tablet->tablet_addr_ = phy_addr;
ObMetaObj<ObTablet> tablet_obj;
tablet_obj.ptr_ = tablet;
tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_pool_;
tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_buffer_pool_;
ObTabletHandle tablet_handle;
tablet_handle.set_obj(tablet_obj);
ret = tablet_map_.compare_and_swap_address_and_object(key, phy_addr, handle, tablet_handle);
ret = tablet_map_.compare_and_swap_addr_and_object(key, phy_addr, handle, tablet_handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ASSERT_EQ(1, tablet_map_.map_.size());
ret = tablet_map_.get_meta_obj(key, allocator, handle);
ret = tablet_map_.get_meta_obj(key, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ASSERT_TRUE(handle.is_valid());
ASSERT_EQ(tablet, handle.get_obj());
ret = tablet_map_.erase(key, allocator);
ObTabletHandle tmp_handle;
ret = tablet_map_.erase(key, tmp_handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ASSERT_EQ(0, tablet_map_.map_.size());
}
@ -298,8 +297,6 @@ TEST_F(TestMetaPointerMap, test_erase_and_load_concurrency)
ObMemtableMgrHandle memtable_mgr_hdl;
ObDDLKvMgrHandle ddl_kv_mgr_hdl;
common::ObIAllocator &allocator = MTL(ObTenantMetaMemMgr*)->get_tenant_allocator();
ret = MTL(ObTenantMetaMemMgr*)->acquire_tablet_memtable_mgr(memtable_mgr_hdl);
ASSERT_EQ(common::OB_SUCCESS, ret);
@ -323,7 +320,7 @@ TEST_F(TestMetaPointerMap, test_erase_and_load_concurrency)
ASSERT_EQ(1, tablet_map_.map_.size());
ObTabletHandle handle;
ret = tablet_map_.get_meta_obj(key, allocator, handle);
ret = tablet_map_.get_meta_obj(key, handle);
ASSERT_EQ(common::OB_ITEM_NOT_SETTED, ret);
ASSERT_TRUE(!handle.is_valid());
ASSERT_EQ(nullptr, handle.get_obj());
@ -333,18 +330,20 @@ TEST_F(TestMetaPointerMap, test_erase_and_load_concurrency)
ObTablet *old_tablet = new ObTablet();
ObMetaObj<ObTablet> old_tablet_obj;
old_tablet_obj.ptr_ = old_tablet;
old_tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_pool_;
old_tablet_obj.pool_ = &MTL(ObTenantMetaMemMgr*)->tablet_buffer_pool_;
handle.set_obj(old_tablet_obj);
/**
ret = tablet_map_.set_meta_obj(key, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
*/
phy_addr.first_id_ = 1;
phy_addr.second_id_ = 2;
phy_addr.offset_ = 0;
phy_addr.size_ = 4096;
phy_addr.type_ = ObMetaDiskAddr::DiskType::BLOCK;
ret = tablet_map_.compare_and_swap_address_and_object(key, phy_addr, handle, handle);
ret = tablet_map_.compare_and_swap_addr_and_object(key, phy_addr, handle, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ObMetaPointerHandle<ObTabletMapKey, ObTablet> ptr_hdl(tablet_map_);
@ -353,12 +352,12 @@ TEST_F(TestMetaPointerMap, test_erase_and_load_concurrency)
ASSERT_TRUE(ptr_hdl.get_resource_ptr()->is_in_memory());
ptr_hdl.get_resource_ptr()->reset_obj();
ret = tablet_map_.erase(key);
ASSERT_EQ(common::OB_SUCCESS, ret);
ASSERT_EQ(0, tablet_map_.map_.size());
ret = tablet_map_.load_and_hook_meta_obj(key, ptr_hdl, allocator, handle);
ASSERT_EQ(common::OB_ENTRY_NOT_EXIST, ret);
// ret = tablet_map_.erase(key);
// ASSERT_EQ(common::OB_SUCCESS, ret);
// ASSERT_EQ(0, tablet_map_.map_.size());
//
// ret = tablet_map_.load_and_hook_meta_obj(key, ptr_hdl, handle);
// ASSERT_EQ(common::OB_ENTRY_NOT_EXIST, ret);
}
class TestMetaDiskAddr : public ::testing::Test