diff --git a/mittest/mtlenv/storage/test_tablet_member_load_and_free.cpp b/mittest/mtlenv/storage/test_tablet_member_load_and_free.cpp index 85cb237d67..45109c40a5 100644 --- a/mittest/mtlenv/storage/test_tablet_member_load_and_free.cpp +++ b/mittest/mtlenv/storage/test_tablet_member_load_and_free.cpp @@ -156,13 +156,13 @@ TEST_F(TestTabletMemberLoadAndFree, storage_schema) // load storage schema, memory type ASSERT_TRUE(tablet->storage_schema_addr_.is_memory_object()); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; ret = tablet->load_storage_schema(arena_allocator, storage_schema); ASSERT_EQ(OB_SUCCESS, ret); ASSERT_NE(nullptr, storage_schema); ASSERT_NE(0, arena_allocator.used()); - ObTablet::free_storage_schema(arena_allocator, storage_schema); + ObTabletObjLoadHelper::free(arena_allocator, storage_schema); arena_allocator.clear(); ASSERT_EQ(0, arena_allocator.used()); @@ -181,7 +181,7 @@ TEST_F(TestTabletMemberLoadAndFree, storage_schema) ASSERT_NE(nullptr, storage_schema); ASSERT_NE(0, arena_allocator.used()); - ObTablet::free_storage_schema(arena_allocator, storage_schema); + ObTabletObjLoadHelper::free(arena_allocator, storage_schema); arena_allocator.clear(); ASSERT_EQ(0, arena_allocator.used()); } diff --git a/src/storage/blocksstable/ob_shared_macro_block_manager.cpp b/src/storage/blocksstable/ob_shared_macro_block_manager.cpp index 24e56fc41a..4399ede267 100644 --- a/src/storage/blocksstable/ob_shared_macro_block_manager.cpp +++ b/src/storage/blocksstable/ob_shared_macro_block_manager.cpp @@ -783,10 +783,10 @@ int ObSharedMacroBlockMgr::prepare_data_desc( { int ret = OB_SUCCESS; ObArenaAllocator tmp_arena("ShrBlkMgrTmp"); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; data_desc.reset(); if (OB_FAIL(tablet.load_storage_schema(tmp_arena, storage_schema))) { - LOG_WARN("fail to load storage schema", K(ret), K(tablet)); + LOG_WARN("fail to load storage schema", K(ret), K(tablet)); } else if (OB_FAIL(data_desc.init( *storage_schema, tablet.get_tablet_meta().ls_id_, @@ -802,7 +802,7 @@ int ObSharedMacroBlockMgr::prepare_data_desc( // from that of old sstable, since the encryption method of one tablet may change before defragmentation LOG_WARN("failed to update basic info from macro_meta", KR(ret), K(basic_meta)); } - ObTablet::free_storage_schema(tmp_arena, storage_schema); + ObTabletObjLoadHelper::free(tmp_arena, storage_schema); return ret; } diff --git a/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp b/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp index df68553a57..58f83726b6 100644 --- a/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp +++ b/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp @@ -552,7 +552,7 @@ bool ObBasicTabletMergeCtx::need_swap_tablet(const ObTablet &tablet, int ObBasicTabletMergeCtx::get_storage_schema() { int ret = OB_SUCCESS; - const ObStorageSchema *schema_on_tablet = nullptr; + ObStorageSchema *schema_on_tablet = nullptr; if (OB_FAIL(get_tablet()->load_storage_schema(mem_ctx_.get_allocator(), schema_on_tablet))) { LOG_WARN("failed to load storage schema", K(ret), K_(tablet_handle)); } else { diff --git a/src/storage/ddl/ob_ddl_merge_task.cpp b/src/storage/ddl/ob_ddl_merge_task.cpp index 0995bd1d53..87a3c3ec40 100644 --- a/src/storage/ddl/ob_ddl_merge_task.cpp +++ b/src/storage/ddl/ob_ddl_merge_task.cpp @@ -482,7 +482,7 @@ int ObTabletDDLUtil::prepare_index_data_desc(ObTablet &tablet, data_desc.reset(); ObLSService *ls_service = MTL(ObLSService *); ObArenaAllocator tmp_arena("DDLIdxDescTmp"); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; const ObTabletID &tablet_id = tablet.get_tablet_meta().tablet_id_; const ObLSID &ls_id = tablet.get_tablet_meta().ls_id_; if (OB_UNLIKELY(!ls_id.is_valid() || !tablet_id.is_valid() || snapshot_version <= 0 || data_format_version < 0)) { @@ -515,7 +515,7 @@ int ObTabletDDLUtil::prepare_index_data_desc(ObTablet &tablet, } } } - ObTablet::free_storage_schema(tmp_arena, storage_schema); + ObTabletObjLoadHelper::free(tmp_arena, storage_schema); return ret; } @@ -618,7 +618,7 @@ int ObTabletDDLUtil::create_ddl_sstable(ObTablet &tablet, { int ret = OB_SUCCESS; ObArenaAllocator tmp_arena("CreateDDLSstTmp"); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; SMART_VAR(ObSSTableMergeRes, res) { if (OB_UNLIKELY(nullptr == sstable_index_builder || !ddl_param.is_valid())) { ret = OB_INVALID_ARGUMENT; @@ -706,7 +706,7 @@ int ObTabletDDLUtil::create_ddl_sstable(ObTablet &tablet, } } } - ObTablet::free_storage_schema(tmp_arena, storage_schema); + ObTabletObjLoadHelper::free(tmp_arena, storage_schema); } return ret; } @@ -725,7 +725,7 @@ int ObTabletDDLUtil::update_ddl_table_store(ObTablet &tablet, ObLSHandle ls_handle; ObTabletHandle tablet_handle; ObArenaAllocator allocator; - const ObStorageSchema *tablet_storage_schema = nullptr; + ObStorageSchema *tablet_storage_schema = nullptr; if (OB_FAIL(ls_service->get_ls(ddl_param.ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) { LOG_WARN("get ls failed", K(ret), K(ddl_param)); } else if (OB_FAIL(tablet.load_storage_schema(allocator, tablet_storage_schema))) { @@ -758,7 +758,7 @@ int ObTabletDDLUtil::update_ddl_table_store(ObTablet &tablet, LOG_INFO("ddl update table store success", K(ddl_param), K(table_store_param), K(sstable)); } } - ObTablet::free_storage_schema(allocator, tablet_storage_schema); + ObTabletObjLoadHelper::free(allocator, tablet_storage_schema); } return ret; } diff --git a/src/storage/ddl/ob_tablet_ddl_kv.cpp b/src/storage/ddl/ob_tablet_ddl_kv.cpp index 1a90877b9e..3bb6bcdac3 100644 --- a/src/storage/ddl/ob_tablet_ddl_kv.cpp +++ b/src/storage/ddl/ob_tablet_ddl_kv.cpp @@ -88,7 +88,7 @@ int ObDDLKV::init_sstable_param(ObTablet &tablet, ObTabletCreateSSTableParam &sstable_param) { int ret = OB_SUCCESS; - const ObStorageSchema *storage_schema_ptr = nullptr; + ObStorageSchema *storage_schema_ptr = nullptr; ObArenaAllocator allocator; if (OB_UNLIKELY(!table_key.is_valid() || !ddl_start_scn.is_valid_and_not_min())) { ret = OB_INVALID_ARGUMENT; @@ -149,7 +149,7 @@ int ObDDLKV::init_sstable_param(ObTablet &tablet, } } } - ObTablet::free_storage_schema(allocator, storage_schema_ptr); + ObTabletObjLoadHelper::free(allocator, storage_schema_ptr); return ret; } diff --git a/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp b/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp index 0c847a6f60..8fb6f6c7da 100644 --- a/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp +++ b/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp @@ -726,7 +726,7 @@ int ObTabletDDLKvMgr::update_tablet(ObTablet &tablet, int ret = OB_SUCCESS; ObLSHandle ls_handle; ObArenaAllocator tmp_arena("DDLUpdateTblTmp"); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); @@ -760,7 +760,7 @@ int ObTabletDDLKvMgr::update_tablet(ObTablet &tablet, LOG_INFO("update tablet success", K(ls_id_), K(tablet_id_), K(param), K(start_scn), K(snapshot_version), K(ddl_checkpoint_scn)); } } - ObTablet::free_storage_schema(tmp_arena, storage_schema); + ObTabletObjLoadHelper::free(tmp_arena, storage_schema); return ret; } @@ -788,7 +788,7 @@ int ObTabletDDLKvMgr::update_ddl_major_sstable(ObTablet &tablet) ObLSHandle ls_handle; ObTabletHandle tablet_handle; ObArenaAllocator allocator; - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); @@ -808,7 +808,7 @@ int ObTabletDDLKvMgr::update_ddl_major_sstable(ObTablet &tablet) LOG_WARN("failed to update tablet table store", K(ret), K(ls_id_), K(tablet_id_), K(param)); } } - ObTablet::free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); return ret; } diff --git a/src/storage/high_availability/ob_physical_copy_task.cpp b/src/storage/high_availability/ob_physical_copy_task.cpp index 0e1de956bd..5908a4eebd 100644 --- a/src/storage/high_availability/ob_physical_copy_task.cpp +++ b/src/storage/high_availability/ob_physical_copy_task.cpp @@ -971,7 +971,7 @@ int ObSSTableCopyFinishTask::create_empty_sstable_() ObTabletHandle tablet_handle; ObTablet *tablet = nullptr; common::ObArenaAllocator tmp_allocator; // for storage schema - const ObStorageSchema *storage_schema_ptr = nullptr; + ObStorageSchema *storage_schema_ptr = nullptr; if (OB_FAIL(ls_->ha_get_tablet(copy_ctx_.tablet_id_, tablet_handle))) { LOG_WARN("failed to get tablet", K(ret), K(copy_ctx_)); } else if (OB_ISNULL(tablet = tablet_handle.get_obj())) { @@ -990,7 +990,7 @@ int ObSSTableCopyFinishTask::create_empty_sstable_() tablet_copy_finish_task_->get_allocator(), table_handle))) { LOG_WARN("failed to create co sstable", K(ret), K(param), K(copy_ctx_)); } - ObTablet::free_storage_schema(tmp_allocator, storage_schema_ptr); + ObTabletObjLoadHelper::free(tmp_allocator, storage_schema_ptr); } else if (OB_FAIL(ObTabletCreateDeleteHelper::create_sstable(param, tablet_copy_finish_task_->get_allocator(), table_handle))) { LOG_WARN("failed to create sstable", K(ret), K(param), K(copy_ctx_)); diff --git a/src/storage/high_availability/ob_storage_ha_reader.cpp b/src/storage/high_availability/ob_storage_ha_reader.cpp index 8a302a9dd7..22b5985642 100644 --- a/src/storage/high_availability/ob_storage_ha_reader.cpp +++ b/src/storage/high_availability/ob_storage_ha_reader.cpp @@ -1563,7 +1563,7 @@ int ObCopySSTableInfoRestoreReader::compare_storage_schema_( int64_t old_storage_schema_stored_col_cnt = 0; const int64_t new_storage_schema_stored_col_cnt = tablet_meta.tablet_meta_.storage_schema_.store_column_cnt_; ObArenaAllocator temp_allocator("RestoreReader", MTL_ID()); - const ObStorageSchema *schema_on_tablet = nullptr; + ObStorageSchema *schema_on_tablet = nullptr; if (OB_FAIL(tablet_handle.get_obj()->load_storage_schema(temp_allocator, schema_on_tablet))) { LOG_WARN("failed to load storage schema", K(ret), K(tablet_handle)); @@ -1585,7 +1585,7 @@ int ObCopySSTableInfoRestoreReader::compare_storage_schema_( "new_mult_version_start", new_multi_version_sstart); #endif } - ObTablet::free_storage_schema(temp_allocator, schema_on_tablet); + ObTabletObjLoadHelper::free(temp_allocator, schema_on_tablet); return ret; } diff --git a/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp b/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp index dffbeefe07..925572a018 100644 --- a/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp +++ b/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp @@ -1059,7 +1059,7 @@ int ObStorageHATabletsBuilder::hold_local_reuse_sstable_( tables_handle.reset(); ObTablet *tablet = nullptr; ObArenaAllocator arena_allocator; - const ObStorageSchema *tablet_storage_schema = nullptr; + ObStorageSchema *tablet_storage_schema = nullptr; const compaction::ObMediumCompactionInfoList *tablet_medium_list = nullptr; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1112,7 +1112,7 @@ int ObStorageHATabletsBuilder::hold_local_reuse_sstable_( } } // end of while } - ObTablet::free_storage_schema(arena_allocator, tablet_storage_schema); + ObTabletObjLoadHelper::free(arena_allocator, tablet_storage_schema); return ret; } @@ -1249,7 +1249,7 @@ int ObStorageHATabletsBuilder::create_remote_logical_sstable_( void *buf = nullptr; ObSSTable *sstable = nullptr; ObArenaAllocator allocator; - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("storage ha tablets builder do not init", K(ret)); @@ -1271,7 +1271,7 @@ int ObStorageHATabletsBuilder::create_remote_logical_sstable_( table_handle.set_sstable(sstable, &arena_allocator); LOG_INFO("succeed to create remote logical sstable", K(tablet_id), K(table_handle), KPC(tablet)); } - ObTablet::free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); return ret; } @@ -2650,7 +2650,7 @@ int ObStorageHATabletBuilderUtil::inner_update_tablet_table_store_with_major_( SCN tablet_snapshot_version; ObTenantMetaMemMgr *meta_mem_mgr = nullptr; ObArenaAllocator allocator; - const ObStorageSchema *tablet_storage_schema = nullptr; + ObStorageSchema *tablet_storage_schema = nullptr; if (multi_version_start < 0 || OB_ISNULL(tablet) || OB_ISNULL(ls) || !table_handle.is_valid()) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table ptr should not be null", K(ret), K(multi_version_start), KP(tablet), K(table_handle), KP(ls)); @@ -2697,7 +2697,7 @@ int ObStorageHATabletBuilderUtil::inner_update_tablet_table_store_with_major_( LOG_WARN("failed to build ha tablet new table store", K(ret), KPC(tablet), K(param)); } } - ObTablet::free_storage_schema(allocator, tablet_storage_schema); + ObTabletObjLoadHelper::free(allocator, tablet_storage_schema); return ret; } diff --git a/src/storage/high_availability/ob_transfer_backfill_tx.cpp b/src/storage/high_availability/ob_transfer_backfill_tx.cpp index 471925a2ac..6ac5804f20 100644 --- a/src/storage/high_availability/ob_transfer_backfill_tx.cpp +++ b/src/storage/high_availability/ob_transfer_backfill_tx.cpp @@ -1439,7 +1439,7 @@ int ObTransferReplaceTableTask::fill_empty_minor_sstable( { int ret = OB_SUCCESS; ObArenaAllocator allocator; - const ObStorageSchema *tablet_storage_schema = nullptr; + ObStorageSchema *tablet_storage_schema = nullptr; ObTableHandleV2 empty_minor_table_handle; if (IS_NOT_INIT) { @@ -1473,7 +1473,7 @@ int ObTransferReplaceTableTask::fill_empty_minor_sstable( LOG_INFO("[TRANSFER_BACKFILL]succ fill empty minor sstable", K(ret), "tablet_id", tablet->get_tablet_meta().tablet_id_, K(empty_minor_table_handle), K(start_scn), K(end_scn)); } - ObTablet::free_storage_schema(allocator, tablet_storage_schema); + ObTabletObjLoadHelper::free(allocator, tablet_storage_schema); } } return ret; @@ -1782,7 +1782,7 @@ int ObTransferReplaceTableTask::build_migration_param_( param.reset(); ObTablet *src_tablet = nullptr; ObArenaAllocator allocator; - const ObStorageSchema *src_storage_schema = nullptr; + ObStorageSchema *src_storage_schema = nullptr; if (IS_NOT_INIT) { ret = OB_NOT_INIT; diff --git a/src/storage/ls/ob_ls.cpp b/src/storage/ls/ob_ls.cpp index 9cddfe5137..240b69205c 100644 --- a/src/storage/ls/ob_ls.cpp +++ b/src/storage/ls/ob_ls.cpp @@ -2180,7 +2180,7 @@ int ObLS::try_update_upper_trans_version_and_gc_sstable( LOG_WARN("failed to check need remove old store", K(tmp_ret), K(snapshot_info), K(tablet_id)); } else if (need_remove) { ObArenaAllocator tmp_arena("RmOldTblTmp", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (OB_TMP_FAIL(tablet->load_storage_schema(tmp_arena, storage_schema))) { LOG_WARN("failed to load storage schema", K(tmp_ret), K(tablet)); } else { @@ -2193,7 +2193,7 @@ int ObLS::try_update_upper_trans_version_and_gc_sstable( K(tablet_id), K(snapshot_info), KPC(tablet)); } } - ObTablet::free_storage_schema(tmp_arena, storage_schema); + ObTabletObjLoadHelper::free(tmp_arena, storage_schema); } } } // end while diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 9735d4dabf..e7247e50d6 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -381,7 +381,7 @@ int ObTablet::init_for_merge( common::ObArenaAllocator tmp_arena_allocator(common::ObMemAttr(MTL_ID(), "InitTablet")); ObTabletMemberWrapper old_table_store_wrapper; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; const ObTabletMdsData &old_mds_data = old_tablet.mds_data_; const bool update_in_major_type_merge = param.need_report_ && param.sstable_->is_major_sstable(); int64_t finish_medium_scn = 0; @@ -484,7 +484,7 @@ int ObTablet::init_for_merge( if (OB_UNLIKELY(!is_inited_)) { reset(); } - ObTablet::free_storage_schema(tmp_arena_allocator, old_storage_schema); + ObTabletObjLoadHelper::free(tmp_arena_allocator, old_storage_schema); return ret; } @@ -502,7 +502,7 @@ int ObTablet::init_for_mds_table_dump( common::ObArenaAllocator tmp_arena_allocator(common::ObMemAttr(MTL_ID(), "InitTabletMDS")); ObTabletMemberWrapper old_table_store_wrapper; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; int64_t finish_medium_scn = 0; ObITable **ddl_kvs_addr = nullptr; int64_t ddl_kv_count = 0; @@ -559,7 +559,7 @@ int ObTablet::init_for_mds_table_dump( is_inited_ = true; LOG_INFO("succeeded to init tablet for mds table dump", K(ret), K(old_tablet), K(flush_scn), KPC(this), K(mds_table_data), K(base_data)); } - ObTablet::free_storage_schema(tmp_arena_allocator, old_storage_schema); + ObTabletObjLoadHelper::free(tmp_arena_allocator, old_storage_schema); return ret; } @@ -668,7 +668,7 @@ int ObTablet::init_for_defragment( common::ObArenaAllocator tmp_arena_allocator(common::ObMemAttr(MTL_ID(), "InitTablet")); ObTabletMemberWrapper old_table_store_wrapper; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; const ObTabletMdsData &old_mds_data = old_tablet.mds_data_; allocator_ = &allocator; ObITable **ddl_kvs_addr = nullptr; @@ -738,7 +738,7 @@ int ObTablet::init_for_defragment( if (OB_UNLIKELY(!is_inited_)) { reset(); } - ObTablet::free_storage_schema(tmp_arena_allocator, old_storage_schema); + ObTabletObjLoadHelper::free(tmp_arena_allocator, old_storage_schema); return ret; } @@ -778,7 +778,7 @@ int ObTablet::init_for_sstable_replace( common::ObArenaAllocator tmp_arena_allocator(common::ObMemAttr(MTL_ID(), "InitTablet")); ObTabletMemberWrapper old_table_store_wrapper; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; const ObStorageSchema *storage_schema = nullptr; int64_t finish_medium_scn = 0; ObITable **ddl_kvs_addr = nullptr; @@ -867,7 +867,7 @@ int ObTablet::init_for_sstable_replace( if (OB_UNLIKELY(!is_inited_)) { reset(); } - ObTablet::free_storage_schema(tmp_arena_allocator, old_storage_schema); + ObTabletObjLoadHelper::free(tmp_arena_allocator, old_storage_schema); #ifdef ERRSIM ObErrsimBackfillPointType point_type(ObErrsimBackfillPointType::TYPE::ERRSIM_REPLACE_SWAP_BEFORE); @@ -939,7 +939,7 @@ int ObTablet::fetch_autoinc_seq(ObTabletMemberWrapper &wrapp return ret; } -int ObTablet::load_storage_schema(common::ObIAllocator &allocator, const ObStorageSchema *&storage_schema) const +int ObTablet::load_storage_schema(common::ObIAllocator &allocator, ObStorageSchema *&storage_schema) const { int ret = OB_SUCCESS; ObStorageSchema *schema = nullptr; @@ -957,7 +957,7 @@ int ObTablet::load_storage_schema(common::ObIAllocator &allocator, const ObStora } if (OB_FAIL(ret)) { - ObTablet::free_storage_schema(allocator, schema); + ObTabletObjLoadHelper::free(allocator, schema); } else if (OB_ISNULL(schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("failed to load storage schema", K(ret), K_(storage_schema_addr)); @@ -965,21 +965,13 @@ int ObTablet::load_storage_schema(common::ObIAllocator &allocator, const ObStora ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected invalid schema", K(ret), K_(storage_schema_addr), KPC(schema)); - ObTablet::free_storage_schema(allocator, schema); + ObTabletObjLoadHelper::free(allocator, schema); } else { storage_schema = schema; } return ret; } -void ObTablet::free_storage_schema(common::ObIAllocator &allocator, const ObStorageSchema *storage_schema) -{ - if (OB_NOT_NULL(storage_schema)) { - storage_schema->~ObStorageSchema(); - allocator.free(const_cast(storage_schema)); - } -} - int ObTablet::read_medium_info_list( common::ObArenaAllocator &allocator, const compaction::ObMediumCompactionInfoList *&medium_info_list) const @@ -1046,7 +1038,7 @@ int ObTablet::init_with_update_medium_info( ObTabletMemberWrapper auto_inc_seqwrapper; const ObTabletMeta &old_tablet_meta = old_tablet.tablet_meta_; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; const ObTabletMdsData &old_mds_data = old_tablet.mds_data_; if (OB_UNLIKELY(is_inited_)) { @@ -1104,7 +1096,7 @@ int ObTablet::init_with_update_medium_info( } } - ObTablet::free_storage_schema(allocator, old_storage_schema); + ObTabletObjLoadHelper::free(allocator, old_storage_schema); if (OB_UNLIKELY(!is_inited_)) { reset(); @@ -1121,7 +1113,7 @@ int ObTablet::init_with_new_snapshot_version( ObTabletMemberWrapper table_store_wrapper; const ObTabletMeta &old_tablet_meta = old_tablet.tablet_meta_; const ObTabletTableStore *old_table_store = nullptr; - const ObStorageSchema *old_storage_schema = nullptr; + ObStorageSchema *old_storage_schema = nullptr; const ObTabletMdsData &old_mds_data = old_tablet.mds_data_; if (OB_UNLIKELY(is_inited_)) { @@ -1178,13 +1170,11 @@ int ObTablet::init_with_new_snapshot_version( is_inited_ = true; } - ObTablet::free_storage_schema(allocator, old_storage_schema); - if (OB_UNLIKELY(!is_inited_)) { reset(); } - ObTablet::free_storage_schema(allocator, old_storage_schema); + ObTabletObjLoadHelper::free(allocator, old_storage_schema); return ret; } @@ -1241,7 +1231,7 @@ int ObTablet::check_sstable_column_checksum() const { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(common::ObMemAttr(MTL_ID(), "CKColCKS")); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; ObTableStoreIterator iter; int64_t schema_col_cnt = 0; int64_t sstable_col_cnt = 0; @@ -1282,7 +1272,7 @@ int ObTablet::check_sstable_column_checksum() const } } } - ObTablet::free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); return ret; } @@ -1472,7 +1462,7 @@ int ObTablet::deserialize_post_work(common::ObArenaAllocator &allocator) LOG_WARN("failed to increase macro ref cnt", K(ret)); } else { ObArenaAllocator arena_allocator(common::ObMemAttr(MTL_ID(), "TmpSchema")); - const ObStorageSchema *schema = nullptr; + ObStorageSchema *schema = nullptr; if (!is_empty_shell()) { if (OB_FAIL(load_storage_schema(arena_allocator, schema))) { LOG_WARN("load storage schema failed", K(ret)); @@ -1486,7 +1476,7 @@ int ObTablet::deserialize_post_work(common::ObArenaAllocator &allocator) K(schema->schema_version_)); tablet_meta_.max_sync_storage_schema_version_ = schema->schema_version_; } - ObTablet::free_storage_schema(arena_allocator, schema); + ObTabletObjLoadHelper::free(arena_allocator, schema); } if (OB_SUCC(ret) && tablet_meta_.has_next_tablet_) { if (next_tablet_guard_.get_obj()->deserialize_post_work(allocator)) { @@ -1823,7 +1813,7 @@ int ObTablet::deserialize( } } if (OB_SUCC(ret) && !is_empty_shell()) { - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (OB_FAIL(load_storage_schema(allocator, storage_schema))) { LOG_WARN("failed to load storage schema", K(ret)); } else if (OB_FAIL(table_store_cache_.init(table_store->get_major_sstables(), @@ -1831,7 +1821,7 @@ int ObTablet::deserialize( storage_schema->is_row_store()))) { LOG_WARN("failed to init table store cache", K(ret), KPC(this)); } - ObTablet::free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); } } @@ -3621,7 +3611,7 @@ int ObTablet::get_schema_version_from_storage_schema(int64_t &schema_version) co { int ret = OB_SUCCESS; const common::ObTabletID &tablet_id = tablet_meta_.tablet_id_; - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; ObArenaAllocator arena_allocator(common::ObMemAttr(MTL_ID(), "TmpSchema")); if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -3631,7 +3621,7 @@ int ObTablet::get_schema_version_from_storage_schema(int64_t &schema_version) co } else { schema_version = storage_schema->schema_version_; } - ObTablet::free_storage_schema(arena_allocator, storage_schema); + ObTabletObjLoadHelper::free(arena_allocator, storage_schema); return ret; } @@ -3642,7 +3632,7 @@ int ObTablet::get_newest_schema_version(int64_t &schema_version) const ObArenaAllocator tmp_allocator; ObSEArray memtables; - const ObStorageSchema *schema_on_tablet = nullptr; + ObStorageSchema *schema_on_tablet = nullptr; int64_t store_column_cnt_in_schema = 0; if (OB_FAIL(get_memtables(memtables, true/*need_active*/))) { LOG_WARN("failed to get memtables", KR(ret), KPC(this)); @@ -3666,7 +3656,7 @@ int ObTablet::get_newest_schema_version(int64_t &schema_version) const schema_version = MAX(max_schema_version_on_memtable, schema_version); } } - ObTablet::free_storage_schema(tmp_allocator, schema_on_tablet); + ObTabletObjLoadHelper::free(tmp_allocator, schema_on_tablet); return ret; } @@ -4035,7 +4025,7 @@ int ObTablet::build_read_info(common::ObArenaAllocator &allocator, const ObTable int ret = OB_SUCCESS; int64_t full_stored_col_cnt = 0; common::ObArenaAllocator tmp_allocator(common::ObMemAttr(MTL_ID(), "TmpSchema")); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; ObSEArray cols_desc; tablet = (tablet == nullptr) ? this : tablet; if (OB_FAIL(tablet->load_storage_schema(tmp_allocator, storage_schema))) { @@ -4053,7 +4043,7 @@ int ObTablet::build_read_info(common::ObArenaAllocator &allocator, const ObTable cols_desc))) { LOG_WARN("fail to init rowkey read info", K(ret), KPC(storage_schema)); } - ObTablet::free_storage_schema(tmp_allocator, storage_schema); + ObTabletObjLoadHelper::free(tmp_allocator, storage_schema); return ret; } @@ -4153,7 +4143,7 @@ int ObTablet::build_migration_tablet_param( mig_tablet_param.is_empty_shell_ = is_empty_shell(); ObArenaAllocator arena_allocator(common::ObMemAttr(MTL_ID(), "BuildMigParam")); - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; const ObTabletAutoincSeq *tablet_autoinc_seq = nullptr; if (!is_empty_shell()) { if (OB_FAIL(load_storage_schema(arena_allocator, storage_schema))) { @@ -4165,7 +4155,6 @@ int ObTablet::build_migration_tablet_param( } else if (OB_FAIL(mig_tablet_param.mds_data_.init(mig_tablet_param.allocator_, mds_data_))) { LOG_WARN("failed to assign mds data", K(ret), K_(mds_data)); } - ObTablet::free_storage_schema(arena_allocator, storage_schema); } else { const ObTabletCreateDeleteMdsUserData &user_data = mds_data_.tablet_status_cache_; const int64_t serialize_size = user_data.get_serialize_size(); @@ -4180,7 +4169,7 @@ int ObTablet::build_migration_tablet_param( mig_tablet_param.mds_data_.tablet_status_committed_kv_.v_.user_data_.assign_ptr(buffer, serialize_size); } } - ObTablet::free_storage_schema(arena_allocator, storage_schema); + ObTabletObjLoadHelper::free(arena_allocator, storage_schema); } return ret; @@ -5004,7 +4993,7 @@ int ObTablet::get_storage_schema_for_transfer_in( int ret = OB_SUCCESS; const share::ObLSID &ls_id = tablet_meta_.ls_id_; const common::ObTabletID &tablet_id = tablet_meta_.tablet_id_; - const ObStorageSchema *tablet_storage_schema = nullptr; + ObStorageSchema *tablet_storage_schema = nullptr; ObIMemtableMgr *memtable_mgr = nullptr; ObArray memtables; int64_t max_column_cnt_in_memtable = 0; @@ -5050,7 +5039,7 @@ int ObTablet::get_storage_schema_for_transfer_in( LOG_INFO("succeeded to get storage schema from transfer source tablet", K(ret), K(storage_schema), K(max_column_cnt_in_memtable), K(max_schema_version_in_memtable), K(old_column_cnt), K(store_column_cnt_in_schema), K(old_schema_version)); } - ObTablet::free_storage_schema(allocator, tablet_storage_schema); + ObTabletObjLoadHelper::free(allocator, tablet_storage_schema); return ret; } @@ -6519,10 +6508,10 @@ int ObTablet::check_transfer_seq_equal(const ObTablet &tablet, const int64_t tra int ObTablet::get_column_store_sstable_checksum(common::ObIArray &column_checksums, ObCOSSTableV2 &co_sstable) { int ret = OB_SUCCESS; - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; ObArenaAllocator allocator; if (OB_FAIL(load_storage_schema(allocator, storage_schema))) { - LOG_WARN("fail to load_storage_schema", K(ret)); + LOG_WARN("fail to load storage schema", K(ret)); } else { const common::ObIArray &column_groups = storage_schema->get_column_groups(); column_checksums.reset(); @@ -6577,7 +6566,7 @@ int ObTablet::get_column_store_sstable_checksum(common::ObIArray &colum } } } - free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); return ret; } diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index 8c7632e792..c2a83a90b3 100644 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -247,13 +247,11 @@ public: int fetch_table_store(ObTabletMemberWrapper &wrapper) const; int load_storage_schema( common::ObIAllocator &allocator, - const ObStorageSchema *&storage_schema) const; + ObStorageSchema *&storage_schema) const; int read_medium_info_list( common::ObArenaAllocator &allocator, const compaction::ObMediumCompactionInfoList *&medium_info_list) const; - static void free_storage_schema(common::ObIAllocator &allocator, const ObStorageSchema *storage_schema); - void set_tablet_addr(const ObMetaDiskAddr &tablet_addr); void set_allocator(ObArenaAllocator *allocator) { allocator_ = allocator; } void set_next_tablet(ObTablet* tablet) { next_tablet_ = tablet; } diff --git a/src/storage/tablet/ob_tablet_persister.cpp b/src/storage/tablet/ob_tablet_persister.cpp index 57dbc3f76f..c5b2322e73 100644 --- a/src/storage/tablet/ob_tablet_persister.cpp +++ b/src/storage/tablet/ob_tablet_persister.cpp @@ -13,6 +13,7 @@ #define USING_LOG_PREFIX STORAGE #include "storage/tablet/ob_tablet_persister.h" +#include "storage/ob_storage_schema.h" #include "storage/slog_ckpt/ob_tenant_checkpoint_slog_handler.h" #include "storage/tx_storage/ob_ls_service.h" #include "storage/meta_mem/ob_tenant_meta_mem_mgr.h" @@ -1119,7 +1120,7 @@ int ObTabletPersister::load_storage_schema_and_fill_write_info( common::ObIArray &write_infos) { int ret = OB_SUCCESS; - const ObStorageSchema *storage_schema = nullptr; + ObStorageSchema *storage_schema = nullptr; if (OB_FAIL(tablet.load_storage_schema(allocator, storage_schema))) { LOG_WARN("fail to load storage schema", K(ret)); } else if (OB_ISNULL(storage_schema)) { @@ -1128,7 +1129,7 @@ int ObTabletPersister::load_storage_schema_and_fill_write_info( } else if (OB_FAIL(fill_write_info(allocator, storage_schema, write_infos))) { LOG_WARN("fail to fill write info", K(ret), KP(storage_schema)); } - ObTablet::free_storage_schema(allocator, storage_schema); + ObTabletObjLoadHelper::free(allocator, storage_schema); return ret; }