From a957b1e96038f615d451f570094d821e510d9d85 Mon Sep 17 00:00:00 2001 From: Ketor Date: Tue, 31 Oct 2023 01:02:22 +0800 Subject: [PATCH] [fix][coordinator] Remove unused code. Signed-off-by: Ketor --- src/coordinator/coordinator_control.cc | 65 ------- src/coordinator/coordinator_control_coor.cc | 121 ------------- src/coordinator/coordinator_control_fsm.cc | 187 -------------------- 3 files changed, 373 deletions(-) diff --git a/src/coordinator/coordinator_control.cc b/src/coordinator/coordinator_control.cc index 0acf21e08..7d1448515 100644 --- a/src/coordinator/coordinator_control.cc +++ b/src/coordinator/coordinator_control.cc @@ -302,19 +302,6 @@ bool CoordinatorControl::Recover() { DINGO_LOG(INFO) << "Recover deleted_table_meta, count=" << kvs.size(); kvs.clear(); - // 7.store_metrics map - if (!meta_reader_->Scan(store_metrics_meta_->Prefix(), kvs)) { - return false; - } - { - BAIDU_SCOPED_LOCK(store_metrics_map_mutex_); - if (!store_metrics_meta_->Recover(kvs)) { - return false; - } - } - DINGO_LOG(INFO) << "Recover store_metrics_meta, count=" << kvs.size(); - kvs.clear(); - // 8.table_metrics map if (!meta_reader_->Scan(table_metrics_meta_->Prefix(), kvs)) { return false; @@ -419,42 +406,6 @@ bool CoordinatorControl::Recover() { DINGO_LOG(INFO) << "Recover index_metrics_meta, count=" << kvs.size(); kvs.clear(); - // // 14.lease map - // if (!meta_reader_->Scan(lease_meta_->Prefix(), kvs)) { - // return false; - // } - // { - // if (!lease_meta_->Recover(kvs)) { - // return false; - // } - // } - // DINGO_LOG(INFO) << "Recover lease_meta, count=" << kvs.size(); - // kvs.clear(); - - // // 15.kv_index map - // if (!meta_reader_->Scan(kv_index_meta_->Prefix(), kvs)) { - // return false; - // } - // { - // if (!kv_index_meta_->Recover(kvs)) { - // return false; - // } - // } - // DINGO_LOG(INFO) << "Recover kv_index_meta, count=" << kvs.size(); - // kvs.clear(); - - // // 16.kv_rev map - // if (!meta_reader_->Scan(kv_rev_meta_->Prefix(), kvs)) { - // return false; - // } - // { - // if (!kv_rev_meta_->Recover(kvs)) { - // return false; - // } - // } - // DINGO_LOG(INFO) << "Recover kv_rev_meta, count=" << kvs.size(); - // kvs.clear(); - // 50.table_index map if (!meta_reader_->Scan(table_index_meta_->Prefix(), kvs)) { return false; @@ -469,16 +420,6 @@ bool CoordinatorControl::Recover() { // build id_epoch, schema_name, table_name, index_name maps BuildTempMaps(); - // // build version_lease_to_key_map_temp_ - // BuildLeaseToKeyMap(); - // DINGO_LOG(INFO) << "Recover lease_to_key_map_temp, count=" << lease_to_key_map_temp_.size(); - - // std::map kv_rev_map; - // kv_rev_map_.GetRawMapCopy(kv_rev_map); - // for (auto& kv : kv_rev_map) { - // DINGO_LOG(INFO) << "kv_rev_map key=" << Helper::StringToHex(kv.first) << " value=" << kv.second.DebugString(); - // } - return true; } @@ -497,12 +438,6 @@ bool CoordinatorControl::Init() { GenerateRootSchemas(root_schema, meta_schema, dingo_schema, mysql_schema, information_schema); // add the initial schemas to schema_map_ - // schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::ROOT_SCHEMA, root_schema)); // raft_kv_put - // schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::META_SCHEMA, meta_schema)); // raft_kv_put - // schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::DINGO_SCHEMA, dingo_schema)); // raft_kv_put - // schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::MYSQL_SCHEMA, mysql_schema)); // raft_kv_put - // schema_map_.insert( - // std::make_pair(pb::meta::ReservedSchemaIds::INFORMATION_SCHEMA, information_schema)); // raft_kv_put schema_map_.Put(pb::meta::ReservedSchemaIds::ROOT_SCHEMA, root_schema); // raft_kv_put schema_map_.Put(pb::meta::ReservedSchemaIds::META_SCHEMA, meta_schema); // raft_kv_put schema_map_.Put(pb::meta::ReservedSchemaIds::DINGO_SCHEMA, dingo_schema); // raft_kv_put diff --git a/src/coordinator/coordinator_control_coor.cc b/src/coordinator/coordinator_control_coor.cc index 3dc67f9e5..e3cb42f4f 100644 --- a/src/coordinator/coordinator_control_coor.cc +++ b/src/coordinator/coordinator_control_coor.cc @@ -3126,95 +3126,6 @@ butil::Status CoordinatorControl::AddStoreOperation(const pb::coordinator::Store return butil::Status::OK(); } -// UpdateRegionMap -// int64_t CoordinatorControl::UpdateRegionMap(std::vector& regions, -// pb::coordinator_internal::MetaIncrement& meta_increment) { -// int64_t region_map_epoch = GetPresentId(pb::coordinator_internal::IdEpochType::EPOCH_REGION); - -// bool need_to_get_next_epoch = false; -// { -// // BAIDU_SCOPED_LOCK(region_map_mutex_); -// for (const auto& region : regions) { -// pb::coordinator_internal::RegionInternal region_to_update; -// int ret = region_map_.Get(region.id(), region_to_update); -// if (ret > 0) { -// DINGO_LOG(INFO) << " update region to region_map in heartbeat, region_id=" << region.id(); - -// // if state not change, just update leader_store_id -// if (region_to_update.state() == region.state()) { -// continue; -// } else { -// // state not equal, need to update region data and apply raft -// DINGO_LOG(INFO) << "REGION STATUS CHANGE region_id = " << region.id() -// << " old status = " << region_to_update.state() << " new status = " << region.state(); -// // maybe need to build a state machine here -// // if a region is set to DELETE, it will never be updated to -// // other normal state -// const auto& region_delete_state_name = -// dingodb::pb::common::RegionState_Name(pb::common::RegionState::REGION_DELETE); -// const auto& region_state_in_map = dingodb::pb::common::RegionState_Name(region_to_update.state()); -// const auto& region_state_in_req = dingodb::pb::common::RegionState_Name(region.state()); - -// // if store want to update a region state from DELETE_* to other -// // NON DELETE_* state, it is illegal -// if (region_state_in_map.rfind(region_delete_state_name, 0) == 0 && -// region_state_in_req.rfind(region_delete_state_name, 0) != 0) { -// DINGO_LOG(INFO) << "illegal intend to update region state from " -// "REGION_DELETE to " -// << region_state_in_req << " region_id=" << region.id(); -// continue; -// } -// } - -// // update meta_increment -// auto* region_increment = meta_increment.add_regions(); -// region_increment->set_id(region.id()); -// region_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::UPDATE); - -// auto* region_increment_region = region_increment->mutable_region(); -// *region_increment_region = region; - -// need_to_get_next_epoch = true; - -// // on_apply -// // region_map_[region.id()] = region; // raft_kv_put -// // region_map_epoch++; // raft_kv_put -// } else if (region.id() == 0) { -// DINGO_LOG(INFO) << " found illegal null region in heartbeat, region_id=0" -// << " name=" << region.definition().name() << " leader_store_id=" << -// region.leader_store_id() -// << " state=" << region.state(); -// } else { -// DINGO_LOG(INFO) << " found illegal region in heartbeat, region_id=" << region.id() -// << " name=" << region.definition().name() << " leader_store_id=" << -// region.leader_store_id() -// << " state=" << region.state(); - -// auto* region_increment = meta_increment.add_regions(); -// region_increment->set_id(region.id()); -// region_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::CREATE); - -// auto* region_increment_region = region_increment->mutable_region(); -// *region_increment_region = region; -// region_increment_region->set_state(::dingodb::pb::common::RegionState::REGION_ILLEGAL); - -// need_to_get_next_epoch = true; - -// // region_map_.insert(std::make_pair(region.id(), region)); // -// // raft_kv_put -// } -// } -// } - -// if (need_to_get_next_epoch) { -// region_map_epoch = GetNextId(pb::coordinator_internal::IdEpochType::EPOCH_REGION, meta_increment); -// } - -// DINGO_LOG(INFO) << "UpdateRegionMapMulti epoch=" << region_map_epoch; - -// return region_map_epoch; -// } - void CoordinatorControl::GetExecutorMap(pb::common::ExecutorMap& executor_map) { int64_t executor_map_epoch = GetPresentId(pb::coordinator_internal::IdEpochType::EPOCH_EXECUTOR); executor_map.set_epoch(executor_map_epoch); @@ -3896,38 +3807,6 @@ int64_t CoordinatorControl::UpdateStoreMetrics(const pb::common::StoreMetrics& s } else { store_metrics_map_.insert(store_metrics.id(), store_metrics); } - - // if (store_metrics_map_.seek(store_metrics.id()) != nullptr) { - // DINGO_LOG(DEBUG) << "STORE METIRCS UPDATE store_metrics.id = " << - // store_metrics.id(); - - // // update meta_increment - // auto* store_metrics_increment = - // meta_increment.add_store_metrics(); - // store_metrics_increment->set_id(store_metrics.id()); - // store_metrics_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::UPDATE); - - // auto* store_metrics_increment_store = - // store_metrics_increment->mutable_store_metrics(); - // *store_metrics_increment_store = store_metrics; - - // // set is_partial_region_metrics - // if (store_metrics.is_partial_region_metrics()) { - // store_metrics_increment->set_is_partial_region_metrics(store_metrics.is_partial_region_metrics()); - // } - // } else { - // DINGO_LOG(INFO) << "NEED ADD NEW STORE store_metrics.id = " << - // store_metrics.id(); - - // // update meta_increment - // auto* store_metrics_increment = - // meta_increment.add_store_metrics(); - // store_metrics_increment->set_id(store_metrics.id()); - // store_metrics_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::CREATE); - - // auto* store_metrics_increment_store = - // store_metrics_increment->mutable_store_metrics(); - // } } // mbvar store diff --git a/src/coordinator/coordinator_control_fsm.cc b/src/coordinator/coordinator_control_fsm.cc index 0356a56fc..ae8d2f05c 100644 --- a/src/coordinator/coordinator_control_fsm.cc +++ b/src/coordinator/coordinator_control_fsm.cc @@ -126,18 +126,6 @@ void CoordinatorControl::OnLeaderStart(int64_t term) { // build id_epoch, schema_name, table_name, index_name maps BuildTempMaps(); - // build lease_to_key_map_temp_ - // BuildLeaseToKeyMap(); - - // clear one time watch map - // { - // BAIDU_SCOPED_LOCK(one_time_watch_map_mutex_); - // one_time_watch_map_.clear(); - // } - - // DINGO_LOG(INFO) << "OnLeaderStart init lease_to_key_map_temp_ finished, term=" << term - // << " count=" << lease_to_key_map_temp_.size(); - coordinator_bvar_.SetValue(1); DINGO_LOG(INFO) << "OnLeaderStart finished, term=" << term; } @@ -155,23 +143,6 @@ void CoordinatorControl::OnLeaderStop() { // clear all index_metrics on follower index_metrics_map_.Clear(); - // clear one time watch map - // { - // BAIDU_SCOPED_LOCK(one_time_watch_map_mutex_); - // for (auto& it : one_time_watch_map_) { - // auto& closure_to_reposne_map = it.second; - // for (auto& ctrm : closure_to_reposne_map) { - // auto* done = ctrm.first; - // if (done) { - // done->Run(); - // } - // } - // } - - // one_time_watch_map_.clear(); - // one_time_watch_closure_map_.clear(); - // } - DINGO_LOG(INFO) << "OnLeaderStop finished"; } @@ -295,18 +266,6 @@ bool CoordinatorControl::LoadMetaToSnapshotFile(std::shared_ptr snapsh DINGO_LOG(INFO) << "Snapshot deleted_table_meta, count=" << kvs.size(); kvs.clear(); - // 7.store_metrics map - // if (!meta_reader_->Scan(snapshot, store_metrics_meta_->Prefix(), kvs)) { - // return false; - // } - - // for (const auto& kv : kvs) { - // auto* snapshot_file_kv = meta_snapshot_file.add_store_metrics_map_kvs(); - // *snapshot_file_kv = kv; - // } - // DINGO_LOG(INFO) << "Snapshot store_metrics_meta, count=" << kvs.size(); - // kvs.clear(); - // 8.table_metrics map if (!meta_reader_->Scan(snapshot, table_metrics_meta_->Prefix(), kvs)) { return false; @@ -402,42 +361,6 @@ bool CoordinatorControl::LoadMetaToSnapshotFile(std::shared_ptr snapsh DINGO_LOG(INFO) << "Snapshot index_metrics_meta, count=" << kvs.size(); kvs.clear(); - // // 14.lease_map_ - // if (!meta_reader_->Scan(snapshot, lease_meta_->Prefix(), kvs)) { - // return false; - // } - - // for (const auto& kv : kvs) { - // auto* snapshot_file_kv = meta_snapshot_file.add_lease_map_kvs(); - // *snapshot_file_kv = kv; - // } - // DINGO_LOG(INFO) << "Snapshot lease_map_, count=" << kvs.size(); - // kvs.clear(); - - // // 15.kv_index_map_ - // if (!meta_reader_->Scan(snapshot, kv_index_meta_->Prefix(), kvs)) { - // return false; - // } - - // for (const auto& kv : kvs) { - // auto* snapshot_file_kv = meta_snapshot_file.add_kv_index_map_kvs(); - // *snapshot_file_kv = kv; - // } - // DINGO_LOG(INFO) << "Snapshot kv_index_map_, count=" << kvs.size(); - // kvs.clear(); - - // // 16.version_kv_rev_map_ - // if (!meta_reader_->Scan(snapshot, kv_rev_meta_->Prefix(), kvs)) { - // return false; - // } - - // for (const auto& kv : kvs) { - // auto* snapshot_file_kv = meta_snapshot_file.add_kv_rev_map_kvs(); - // *snapshot_file_kv = kv; - // } - // DINGO_LOG(INFO) << "Snapshot version_kv_rev_map_, count=" << kvs.size(); - // kvs.clear(); - // 50.table_index map if (!meta_reader_->Scan(snapshot, table_index_meta_->Prefix(), kvs)) { return false; @@ -710,34 +633,6 @@ bool CoordinatorControl::LoadMetaFromSnapshotFile(pb::coordinator_internal::Meta DINGO_LOG(INFO) << "LoadSnapshot deleted_table_meta, count=" << kvs.size(); kvs.clear(); - // 7.store_metrics map - // kvs.reserve(meta_snapshot_file.store_metrics_map_kvs_size()); - // for (int i = 0; i < meta_snapshot_file.store_metrics_map_kvs_size(); i++) { - // kvs.push_back(meta_snapshot_file.store_metrics_map_kvs(i)); - // } - // { - // BAIDU_SCOPED_LOCK(store_metrics_map_mutex_); - // if (!store_metrics_meta_->Recover(kvs)) { - // return false; - // } - // } - // { // remove data in rocksdb - // if (!meta_writer_->DeletePrefix(store_metrics_meta_->internal_prefix)) { - // DINGO_LOG(ERROR) << "Coordinator delete store_metrics_meta_ range failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator delete range store_metrics_meta_ success in LoadMetaFromSnapshotFile"; - - // // write data to rocksdb - // if (!meta_writer_->Put(kvs)) { - // DINGO_LOG(ERROR) << "Coordinator write store_metrics_meta_ failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator put store_metrics_meta_ success in LoadMetaFromSnapshotFile"; - // } - // DINGO_LOG(INFO) << "LoadSnapshot store_metrics_meta, count=" << kvs.size(); - // kvs.clear(); - // 8.table_metrics map kvs.reserve(meta_snapshot_file.table_metrics_map_kvs_size()); for (int i = 0; i < meta_snapshot_file.table_metrics_map_kvs_size(); i++) { @@ -960,88 +855,6 @@ bool CoordinatorControl::LoadMetaFromSnapshotFile(pb::coordinator_internal::Meta DINGO_LOG(INFO) << "LoadSnapshot index_metrics_meta, count=" << kvs.size(); kvs.clear(); - // // 14.lease_map_ - // kvs.reserve(meta_snapshot_file.lease_map_kvs_size()); - // for (int i = 0; i < meta_snapshot_file.lease_map_kvs_size(); i++) { - // kvs.push_back(meta_snapshot_file.lease_map_kvs(i)); - // } - // { - // // BAIDU_SCOPED_LOCK(lease_map_mutex_); - // if (!lease_meta_->Recover(kvs)) { - // return false; - // } - - // // remove data in rocksdb - // if (!meta_writer_->DeletePrefix(lease_meta_->internal_prefix)) { - // DINGO_LOG(ERROR) << "Coordinator delete lease_meta_ range failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator delete range lease_meta_ success in LoadMetaFromSnapshotFile"; - - // // write data to rocksdb - // if (!meta_writer_->Put(kvs)) { - // DINGO_LOG(ERROR) << "Coordinator write lease_meta_ failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator put lease_meta_ success in LoadMetaFromSnapshotFile"; - // } - // DINGO_LOG(INFO) << "LoadSnapshot version_lease_meta, count=" << kvs.size(); - // kvs.clear(); - - // // 15.kv_index_map_ - // kvs.reserve(meta_snapshot_file.kv_index_map_kvs_size()); - // for (int i = 0; i < meta_snapshot_file.kv_index_map_kvs_size(); i++) { - // kvs.push_back(meta_snapshot_file.kv_index_map_kvs(i)); - // } - // { - // if (!kv_index_meta_->Recover(kvs)) { - // return false; - // } - - // // remove data in rocksdb - // if (!meta_writer_->DeletePrefix(kv_index_meta_->internal_prefix)) { - // DINGO_LOG(ERROR) << "Coordinator delete kv_index_meta_ range failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator delete range kv_index_meta_ success in LoadMetaFromSnapshotFile"; - - // // write data to rocksdb - // if (!meta_writer_->Put(kvs)) { - // DINGO_LOG(ERROR) << "Coordinator write kv_index_meta_ failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator put kv_index_meta_ success in LoadMetaFromSnapshotFile"; - // } - // DINGO_LOG(INFO) << "LoadSnapshot version_kv_meta, count=" << kvs.size(); - // kvs.clear(); - - // // 16.kv_rev_map_ - // kvs.reserve(meta_snapshot_file.kv_rev_map_kvs_size()); - // for (int i = 0; i < meta_snapshot_file.kv_rev_map_kvs_size(); i++) { - // kvs.push_back(meta_snapshot_file.kv_rev_map_kvs(i)); - // } - // { - // if (!kv_rev_meta_->Recover(kvs)) { - // return false; - // } - - // // remove data in rocksdb - // if (!meta_writer_->DeletePrefix(kv_rev_meta_->internal_prefix)) { - // DINGO_LOG(ERROR) << "Coordinator delete kv_rev_meta_ range failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator delete range kv_rev_meta_ success in LoadMetaFromSnapshotFile"; - - // // write data to rocksdb - // if (!meta_writer_->Put(kvs)) { - // DINGO_LOG(ERROR) << "Coordinator write kv_rev_meta_ failed in LoadMetaFromSnapshotFile"; - // return false; - // } - // DINGO_LOG(INFO) << "Coordinator put kv_rev_meta_ success in LoadMetaFromSnapshotFile"; - // } - // DINGO_LOG(INFO) << "LoadSnapshot version_kv_rev_meta, count=" << kvs.size(); - // kvs.clear(); - // 50.table_index map kvs.reserve(meta_snapshot_file.table_index_map_kvs_size()); for (int i = 0; i < meta_snapshot_file.table_index_map_kvs_size(); i++) {