diff --git a/src/observer/ob_service.cpp b/src/observer/ob_service.cpp index 7577ccc4f..7af8e6893 100644 --- a/src/observer/ob_service.cpp +++ b/src/observer/ob_service.cpp @@ -2923,8 +2923,11 @@ int ObService::inner_fill_tablet_info_( } else if (OB_ISNULL(gctx_.config_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("gctx_.config_ is null", KR(ret), K(tenant_id), K(tablet_id)); + } else if (ls->is_cs_replica() && !tablet->get_tablet_meta().ha_status_.is_data_status_complete()) { + ret = OB_EAGAIN; + LOG_WARN("tablet is not complete in cs replica now, need retry later", KR(ret), KPC(ls), KPC(tablet)); } else if (OB_FAIL(ObCSReplicaUtil::check_need_wait_major_convert(*ls, tablet_id, *tablet, need_wait_major_convert_in_cs_replica))) { - LOG_WARN("fail to check need wait major convert in cs replica", K(ret), KPC(ls), K(tablet)); + LOG_WARN("fail to check need wait major convert in cs replica", K(ret), KPC(ls), KPC(tablet)); } else if (need_wait_major_convert_in_cs_replica) { ret = OB_EAGAIN; LOG_WARN("need wait major convert for cs replica", K(ret), K(tablet_id)); diff --git a/src/storage/column_store/ob_column_store_replica_util.cpp b/src/storage/column_store/ob_column_store_replica_util.cpp index 1df0e938d..c7297ace5 100644 --- a/src/storage/column_store/ob_column_store_replica_util.cpp +++ b/src/storage/column_store/ob_column_store_replica_util.cpp @@ -149,6 +149,10 @@ int ObCSReplicaUtil::check_need_wait_major_convert( need_wait_major_convert = ObITable::is_row_store_major_sstable(sstable->get_key().table_type_); } } + + if (ls.is_cs_replica()) { + LOG_INFO("[CS-Replica] Finish check need wait major convert", K(ret), K(tablet_id), K(need_process_cs_replica), K(need_wait_major_convert), K(ls), KPC(storage_schema), K(tablet), KPC(table_store), KPC(sstable)); + } ObTabletObjLoadHelper::free(arena_allocator, storage_schema); return ret; } diff --git a/src/storage/high_availability/ob_cs_replica_migration.h b/src/storage/high_availability/ob_cs_replica_migration.h index e30502e32..fdfbaec00 100644 --- a/src/storage/high_availability/ob_cs_replica_migration.h +++ b/src/storage/high_availability/ob_cs_replica_migration.h @@ -74,7 +74,8 @@ public: OB_INLINE int set_convert_progressing(const ObTabletID &tablet_id) { return set_convert_status(tablet_id, ObTabletCOConvertCtx::Status::PROGRESSING); } int get_co_dag_net_id(const ObTabletID &tablet_id, share::ObDagId &co_dag_net_id) const; int check_and_schedule(ObLS &ls); - INHERIT_TO_STRING_KV("ObHATabletGroupCtx", ObHATabletGroupCtx, K_(finish_migration_cnt), K_(finish_check_cnt), K_(retry_exhausted_cnt), "map_size", idx_map_.size(), K_(convert_ctxs)); + // move tablet_id_array last to prevent log ignore other parameters + TO_STRING_KV(K_(finish_migration_cnt), K_(finish_check_cnt), K_(retry_exhausted_cnt), "map_size", idx_map_.size(), K_(convert_ctxs), K_(index), K_(tablet_id_array)); public: static int check_need_convert(const ObTablet &tablet, bool &need_convert); static int update_deleted_data_tablet_status( diff --git a/src/storage/ls/ob_ls_tablet_service.cpp b/src/storage/ls/ob_ls_tablet_service.cpp index c9e23a4ba..234fd061b 100644 --- a/src/storage/ls/ob_ls_tablet_service.cpp +++ b/src/storage/ls/ob_ls_tablet_service.cpp @@ -1580,6 +1580,7 @@ int ObLSTabletService::update_tablet_snapshot_version( const ObTabletMapKey key(ls_id, tablet_id); ObMetaDiskAddr disk_addr; const ObTabletPersisterParam param(ls_id, ls_->get_ls_epoch(), tablet_id); + ObTabletDataStatus::STATUS current_status = ObTabletDataStatus::DATA_STATUS_MAX; if (OB_FAIL(ObTabletCreateDeleteHelper::acquire_tmp_tablet(key, allocator, tmp_tablet_hdl))) { if (OB_ENTRY_NOT_EXIST == ret) { @@ -1588,7 +1589,9 @@ int ObLSTabletService::update_tablet_snapshot_version( LOG_WARN("failed to acquire tablet", K(ret), K(key)); } } else if (FALSE_IT(tmp_tablet = tmp_tablet_hdl.get_obj())) { - } else if (OB_FAIL(tmp_tablet->init_with_new_snapshot_version(allocator, *old_tablet, snapshot_version))) { + } else if (OB_FAIL(old_tablet->tablet_meta_.ha_status_.get_data_status(current_status))) { + LOG_WARN("failed to get data status", K(ret), KPC(old_tablet)); + } else if (OB_FAIL(tmp_tablet->init_with_replace_members(allocator, *old_tablet, snapshot_version, current_status))) { LOG_WARN("failed to init tablet", K(ret), KPC(old_tablet)); } else if (FALSE_IT(time_guard.click("InitNew"))) { } else if (OB_FAIL(ObTabletPersister::persist_and_transform_tablet(param, *tmp_tablet, new_tablet_hdl))) { @@ -1700,41 +1703,47 @@ int ObLSTabletService::update_tablet_ha_data_status( time_guard.click("GetTablet"); ObMetaDiskAddr disk_addr; const ObTabletMapKey key(ls_->get_ls_id(), tablet_id); - ObTablet *tablet = tablet_handle.get_obj(); + ObTablet *old_tablet = tablet_handle.get_obj(); + ObTablet *tmp_tablet = nullptr; + common::ObArenaAllocator allocator("UpdateSchema", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID(), ObCtxIds::DEFAULT_CTX_ID); ObTabletHandle new_tablet_handle; + ObTabletHandle tmp_tablet_handle; const ObTabletPersisterParam param(ls_->get_ls_id(), ls_->get_ls_epoch(), tablet_id); + bool is_row_store_with_co_major = false; - if (OB_FAIL(tablet->tablet_meta_.ha_status_.get_data_status(current_status))) { - LOG_WARN("failed to get data status", K(ret), KPC(tablet)); + if (OB_FAIL(old_tablet->tablet_meta_.ha_status_.get_data_status(current_status))) { + LOG_WARN("failed to get data status", K(ret), KPC(old_tablet)); } else if (OB_FAIL(ObTabletDataStatus::check_can_change_status(current_status, data_status, can_change))) { - LOG_WARN("failed to check can change status", K(ret), K(current_status), K(data_status), KPC(tablet)); + LOG_WARN("failed to check can change status", K(ret), K(current_status), K(data_status), KPC(old_tablet)); } else if (!can_change) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("can not change data status", K(ret), K(current_status), K(data_status), KPC(tablet)); + LOG_WARN("can not change data status", K(ret), K(current_status), K(data_status), KPC(old_tablet)); } else if (current_status == data_status) { LOG_INFO("data status is same, skip update", K(tablet_id), K(current_status), K(data_status)); - } else if (OB_FAIL(tablet->tablet_meta_.ha_status_.set_data_status(data_status))) { - LOG_WARN("failed to set data status", K(ret), KPC(tablet), K(data_status)); - } else { - if (OB_FAIL(tablet->check_valid())) { - LOG_WARN("failed to check tablet valid", K(ret), K(data_status), KPC(tablet)); - } else if (OB_FAIL(ObTabletPersister::persist_and_transform_tablet(param, *tablet, new_tablet_handle))) { - LOG_WARN("fail to persist and transform tablet", K(ret), KPC(tablet), K(new_tablet_handle)); - } else if (FALSE_IT(time_guard.click("Persist"))) { - } else if (FALSE_IT(disk_addr = new_tablet_handle.get_obj()->tablet_addr_)) { - } else if (OB_FAIL(safe_update_cas_tablet(key, disk_addr, tablet_handle, new_tablet_handle, time_guard))) { - LOG_WARN("fail to update tablet", K(ret), K(key), K(disk_addr)); + } else if (ObTabletDataStatus::is_complete(data_status) // may reuse exist co major in cs replica when rebuild, but tablet is row store like src + && OB_FAIL(old_tablet->check_row_store_with_co_major(is_row_store_with_co_major))) { + LOG_WARN("failed to check row store with co major", K(ret), KPC(old_tablet)); + } else if (OB_FAIL(ObTabletCreateDeleteHelper::acquire_tmp_tablet(key, allocator, tmp_tablet_handle))) { + if (OB_ENTRY_NOT_EXIST == ret) { + ret = OB_TABLET_NOT_EXIST; } else { - LOG_INFO("succeeded to update tablet ha data status", K(ret), K(key), K(disk_addr), K(data_status), K(tablet_handle)); - } - - if (OB_FAIL(ret)) { - int tmp_ret = OB_SUCCESS; - if (OB_SUCCESS != (tmp_ret = tablet->tablet_meta_.ha_status_.set_data_status(current_status))) { - LOG_WARN("failed to set data status", K(tmp_ret), K(current_status), KPC(tablet)); - ob_abort(); - } + LOG_WARN("failed to acquire tablet", K(ret), K(key)); } + } else if (FALSE_IT(tmp_tablet = tmp_tablet_handle.get_obj())) { + // need update tablet to column store with column store storage schema when rebuild reuse old co major in cs replica + } else if (OB_FAIL(tmp_tablet->init_with_replace_members(allocator, *old_tablet, old_tablet->tablet_meta_.snapshot_version_, data_status, is_row_store_with_co_major))) { + LOG_WARN("failed to init tablet", K(ret), KPC(old_tablet)); + } else if (FALSE_IT(time_guard.click("InitNew"))) { + } else if (OB_FAIL(tmp_tablet->check_valid())) { + LOG_WARN("failed to check tablet valid", K(ret), K(data_status), KPC(tmp_tablet)); + } else if (OB_FAIL(ObTabletPersister::persist_and_transform_tablet(param, *tmp_tablet, new_tablet_handle))) { + LOG_WARN("fail to persist and transform tablet", K(ret), KPC(tmp_tablet), K(new_tablet_handle)); + } else if (FALSE_IT(time_guard.click("Persist"))) { + } else if (FALSE_IT(disk_addr = new_tablet_handle.get_obj()->tablet_addr_)) { + } else if (OB_FAIL(safe_update_cas_tablet(key, disk_addr, tablet_handle, new_tablet_handle, time_guard))) { + LOG_WARN("fail to update tablet", K(ret), K(key), K(disk_addr)); + } else { + LOG_INFO("succeeded to update tablet ha data status", K(ret), K(key), K(disk_addr), K(data_status), K(tablet_handle), K(tmp_tablet_handle), K(is_row_store_with_co_major), K(time_guard)); } } return ret; diff --git a/src/storage/ob_storage_schema.cpp b/src/storage/ob_storage_schema.cpp index ef1f13674..924d46bb9 100644 --- a/src/storage/ob_storage_schema.cpp +++ b/src/storage/ob_storage_schema.cpp @@ -541,9 +541,15 @@ int ObStorageSchema::init( if (OB_FAIL(ObStorageSchema::generate_cs_replica_cg_array())) { STORAGE_LOG(WARN, "failed to generate_cs_replica_cg_array", K(ret)); } - } else if (NULL != column_group_schema && OB_FAIL(deep_copy_column_group_array(allocator, *column_group_schema))) { - STORAGE_LOG(WARN, "failed to deep copy column array from column group schema", K(ret), K(old_schema), KPC(column_group_schema)); - } else if (NULL == column_group_schema && OB_FAIL(deep_copy_column_group_array(allocator, old_schema))) { + } else if (NULL != column_group_schema) { + if (OB_FAIL(deep_copy_column_group_array(allocator, *column_group_schema))) { + STORAGE_LOG(WARN, "failed to deep copy column array from column group schema", K(ret), K(old_schema), KPC(column_group_schema)); + } else if (!old_schema.is_cs_replica_compat() && column_group_schema->is_cs_replica_compat()) { + // use row store storage schema from src when ls rebuild, but use column group from old tablet to init cg schemas + is_cs_replica_compat_ = true; + STORAGE_LOG(INFO, "[CS-Replica] take old schema from param and column group from old tablet in cs replica", K(ret), K(old_schema), KPC(column_group_schema)); + } + } else if (OB_FAIL(deep_copy_column_group_array(allocator, old_schema))) { STORAGE_LOG(WARN, "failed to deep copy column array", K(ret), K(old_schema)); } diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index af70cb87b..6b44949b7 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -1327,10 +1327,12 @@ int ObTablet::update_tablet_status_from_sstable(const bool expect_persist_status return ret; } -int ObTablet::init_with_new_snapshot_version( +int ObTablet::init_with_replace_members( common::ObArenaAllocator &allocator, const ObTablet &old_tablet, - const int64_t snapshot_version) + const int64_t snapshot_version, + const ObTabletDataStatus::STATUS &data_status, + bool need_generate_cs_replica_cg_array/*=false*/) { int ret = OB_SUCCESS; ObTabletMemberWrapper table_store_wrapper; @@ -1341,9 +1343,11 @@ int ObTablet::init_with_new_snapshot_version( if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("init twice", K(ret), K(is_inited_)); - } else if (OB_UNLIKELY(!old_tablet.is_valid() || 0 >= snapshot_version)) { + } else if (OB_UNLIKELY(!old_tablet.is_valid() || 0 >= snapshot_version + || !ObTabletDataStatus::is_valid(data_status) + || (need_generate_cs_replica_cg_array && !old_tablet.is_row_store()))) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid args", K(ret), K(old_tablet), K(snapshot_version)); + LOG_WARN("invalid args", K(ret), K(old_tablet), K(snapshot_version), K(need_generate_cs_replica_cg_array)); } else if (OB_UNLIKELY(!pointer_hdl_.is_valid()) || OB_ISNULL(log_handler_)) { ret = OB_ERR_UNEXPECTED; @@ -1358,8 +1362,9 @@ int ObTablet::init_with_new_snapshot_version( LOG_WARN("fail to load storage schema", K(ret)); } else if (OB_FAIL(tablet_meta_.assign(old_tablet_meta))) { LOG_WARN("failed to copy tablet meta", K(ret), K(old_tablet_meta)); - } else { - tablet_meta_.snapshot_version_ = MAX(snapshot_version, tablet_meta_.snapshot_version_); + } else if (FALSE_IT(tablet_meta_.snapshot_version_ = MAX(snapshot_version, tablet_meta_.snapshot_version_))) { + } else if (OB_FAIL(tablet_meta_.ha_status_.set_data_status(data_status))) { + LOG_WARN("failed to set data status", K(ret), K(data_status), K_(tablet_meta)); } if (FAILEDx(ObTabletObjLoadHelper::alloc_and_new(allocator, table_store_addr_.ptr_))) { @@ -1370,7 +1375,7 @@ int ObTablet::init_with_new_snapshot_version( LOG_WARN("failed to update start scn", K(ret), KPC(old_table_store)); } else if (OB_FAIL(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(), table_store_addr_.get_ptr()->get_minor_sstables(), - old_tablet.table_store_cache_.is_row_store_))) { + need_generate_cs_replica_cg_array ? false /*is_row_store*/ : old_tablet.table_store_cache_.is_row_store_))) { LOG_WARN("failed to init table store cache", K(ret), KPC(this)); } else if (OB_FAIL(init_aggregated_info(allocator, nullptr/* link_writer, tmp_tablet do no write */))) { LOG_WARN("fail to init aggregated info", K(ret)); @@ -1379,6 +1384,13 @@ int ObTablet::init_with_new_snapshot_version( LOG_WARN("failed to increase sstables ref cnt", K(ret)); } else if (OB_FAIL(check_table_store_flag_match_with_table_store_(table_store_addr_.get_ptr()))) { LOG_WARN("failed to check table store flag match with table store", K(ret), K(old_tablet), K_(table_store_addr)); + } else if (need_generate_cs_replica_cg_array) { + if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, storage_schema_addr_.ptr_))) { + LOG_WARN("fail to allocate and new object", K(ret)); + } else if (OB_FAIL(storage_schema_addr_.get_ptr()->init(allocator, *old_storage_schema, false /*skip_column_info*/, + nullptr /*column_group_schema*/, true /*need_generate_cs_replica_cg_array*/))) { + LOG_WARN("fail to initialize tablet member", K(ret), K(storage_schema_addr_)); + } } else { ALLOC_AND_INIT(allocator, storage_schema_addr_, *old_storage_schema); } @@ -1389,7 +1401,7 @@ int ObTablet::init_with_new_snapshot_version( if (old_tablet.get_tablet_meta().has_next_tablet_) { set_next_tablet_guard(old_tablet.next_tablet_guard_); } - LOG_INFO("succeeded to init tablet with new snapshot", K(ret), K(snapshot_version), KPC(this), K(old_tablet)); + LOG_INFO("succeeded to init tablet with new snapshot", K(ret), K(snapshot_version), K(data_status), K(need_generate_cs_replica_cg_array), KPC(this), K(old_tablet)); is_inited_ = true; } @@ -5776,6 +5788,34 @@ int ObTablet::check_cs_replica_compat_schema(bool &is_cs_replica_compat) const return ret; } +int ObTablet::check_row_store_with_co_major(bool &is_row_store_with_co_major) const +{ + int ret = OB_SUCCESS; + ObTabletMemberWrapper table_store_wrapper; + const ObTabletTableStore *table_store = nullptr; + const ObITable *major_sstable = nullptr; + is_row_store_with_co_major = false; + + if (IS_NOT_INIT) { + ret = OB_NOT_INIT; + LOG_WARN("not inited", K(ret)); + } else if (!table_store_cache_.is_row_store_) { + // current is column store tablet, skip it + } else if (OB_FAIL(fetch_table_store(table_store_wrapper))) { + LOG_WARN("fail to fetch table store", K(ret)); + } else if (OB_FAIL(table_store_wrapper.get_member(table_store))) { + LOG_WARN("fail to get table store", K(ret), K(table_store_wrapper)); + } else if (table_store->get_major_sstables().empty()) { + } else if (OB_ISNULL(major_sstable = table_store->get_major_sstables().get_boundary_table(true /*is_last*/))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("fail to get last table", K(ret)); + } else if (ObITable::is_column_store_major_sstable(major_sstable->get_key().table_type_)) { + is_row_store_with_co_major = true; + LOG_INFO("[CS-Replica] find store type mismatch last major sstable", K(ret), K(table_store_cache_), KPC(table_store), K(is_row_store_with_co_major)); + } + return ret; +} + int ObTablet::pre_process_cs_replica(ObTabletDirectLoadInsertParam &direct_load_param) { int ret = OB_SUCCESS; diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index c4a38a7b3..72ed576bf 100644 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -219,10 +219,12 @@ public: const bool clear_wait_check_flag); // TODO(@gaishun.gs && @fengjingkun.fjk) tmp interface for force_freeze on column store, should removed later. - int init_with_new_snapshot_version( + int init_with_replace_members( common::ObArenaAllocator &allocator, const ObTablet &old_tablet, - const int64_t snapshot_version); + const int64_t snapshot_version, + const ObTabletDataStatus::STATUS &data_status, + bool need_generate_cs_replica_cg_array = false); // init for mds table mini merge int init_with_mds_sstable( common::ObArenaAllocator &allocator, @@ -468,6 +470,7 @@ public: // column store replica int check_cs_replica_compat_schema(bool &is_cs_replica_compat) const; + int check_row_store_with_co_major(bool &is_row_store_with_co_major) const; int pre_process_cs_replica(ObTabletDirectLoadInsertParam &direct_load_param); // other diff --git a/unittest/storage/CMakeLists.txt b/unittest/storage/CMakeLists.txt index 2822c4fef..9373b9a10 100644 --- a/unittest/storage/CMakeLists.txt +++ b/unittest/storage/CMakeLists.txt @@ -40,6 +40,7 @@ add_subdirectory(utl_file) add_subdirectory(tx_table) add_subdirectory(ddl) add_subdirectory(share_storage) +add_subdirectory(column_store_replica) storage_unittest(test_io_manager) storage_unittest(test_iocb_pool) diff --git a/unittest/storage/column_store_replica/CMakeLists.txt b/unittest/storage/column_store_replica/CMakeLists.txt new file mode 100644 index 000000000..abe2a4cd7 --- /dev/null +++ b/unittest/storage/column_store_replica/CMakeLists.txt @@ -0,0 +1 @@ +storage_unittest(test_cs_replica_migration) \ No newline at end of file diff --git a/unittest/storage/column_store_replica/test_cs_replica_migration.cpp b/unittest/storage/column_store_replica/test_cs_replica_migration.cpp new file mode 100644 index 000000000..9d6b8bb38 --- /dev/null +++ b/unittest/storage/column_store_replica/test_cs_replica_migration.cpp @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2024 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX STORAGE +#include + +#define protected public +#define private public + +#include "src/storage/high_availability/ob_cs_replica_migration.h" + + +namespace oceanbase +{ +namespace storage +{ +namespace unittest +{ + +class TestCSReplicaMigration: public ::testing::Test +{ +public: + TestCSReplicaMigration(); + virtual ~TestCSReplicaMigration() = default; +public: + static int mock_tablet_id_array( + int64_t start_tablet_id, + int64_t count, + ObIArray &tablet_id_array); +}; + +int TestCSReplicaMigration::mock_tablet_id_array( + int64_t start_tablet_id, + int64_t count, + ObIArray &tablet_id_array) +{ + int ret = OB_SUCCESS; + for (int64_t i = 0; OB_SUCC(ret) && i < count; ++i) { + ObLogicTabletID logic_tablet_id; + if (OB_FAIL(logic_tablet_id.init(ObTabletID(start_tablet_id + i), 0))) { + LOG_WARN("failed to init logic tablet id", K(ret)); + } else if (OB_FAIL(tablet_id_array.push_back(logic_tablet_id))) { + LOG_WARN("failed to push back", K(ret)); + } + } + return ret; +} + +class A +{ +public: + A(int a) : a_(a) { + LOG_INFO("print a", K_(a)); + } + TO_STRING_KV(K_(a)); +public: + int a_; +}; + +class B : public A +{ +public: + B(int a, int b) : A(a), b_(b) { + LOG_INFO("print b", K_(b)); + } + INHERIT_TO_STRING_KV("A", A, K_(b)); +public: + int b_; +}; + +TEST(TestCSReplicaMigration, test_group_co_ctx_pretty_print) +{ + int ret = OB_SUCCESS; + A a(1); + B b(1, 2); + LOG_INFO("print a", K(a)); + LOG_INFO("print b", K(b)); + + ObHATabletGroupCOConvertCtx ctx; + ObHATabletGroupCtx base_ctx; + ObSEArray tablet_id_array; + ASSERT_EQ(OB_SUCCESS,TestCSReplicaMigration::mock_tablet_id_array(200001, 100, tablet_id_array)); + ASSERT_EQ(OB_SUCCESS, ctx.init(tablet_id_array)); + ASSERT_EQ(OB_SUCCESS, base_ctx.init(tablet_id_array)); + LOG_INFO("print ctx", K(ctx)); + LOG_INFO("print base_ctx", K(base_ctx)); +} + +TEST(TestCSReplicaMigration, test_ha_tablet_group_mgr) +{ + int ret = OB_SUCCESS; + ObHATabletGroupMgr mgr; + ObSEArray tablet_id_array[3]; + ASSERT_EQ(OB_SUCCESS, mgr.init()); + for (int64_t i = 0; OB_SUCC(ret) && i < 3; ++i) { + ASSERT_EQ(OB_SUCCESS, TestCSReplicaMigration::mock_tablet_id_array(200001 + i * 10000, 100, tablet_id_array[i])); + ASSERT_EQ(OB_SUCCESS, mgr.build_tablet_group_ctx(tablet_id_array[i], ObHATabletGroupCtx::TabletGroupCtxType::CS_REPLICA_TYPE)); + } + LOG_INFO("print mgr", K(mgr)); +} + +} // end unittest +} // end storage +} // end oceanbase + +int main(int argc, char **argv) +{ + oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); + OB_LOGGER.set_log_level("INFO"); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}