From 6c7b2e1dfda28df2f57dfe09c1fa6f238a34a4e7 Mon Sep 17 00:00:00 2001 From: dl239 Date: Tue, 15 Feb 2022 14:33:57 +0800 Subject: [PATCH] fix: update tablet client --- src/nameserver/name_server_impl.cc | 9 +++++---- src/nameserver/name_server_impl.h | 2 +- src/tablet/tablet_impl.cc | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/nameserver/name_server_impl.cc b/src/nameserver/name_server_impl.cc index 631906d044a..2fd8336b352 100644 --- a/src/nameserver/name_server_impl.cc +++ b/src/nameserver/name_server_impl.cc @@ -622,6 +622,7 @@ bool NameServerImpl::Recover() { } RecoverOfflineTablet(); } + UpdateRealEpMapToTablet(false); if (FLAGS_use_name) { UpdateRemoteRealEpMap(); } @@ -1137,7 +1138,7 @@ void NameServerImpl::UpdateTablets(const std::vector& endpoints) { } } thread_pool_.AddTask(boost::bind(&NameServerImpl::DistributeTabletMode, this)); - thread_pool_.AddTask(boost::bind(&NameServerImpl::UpdateRealEpMapToTablet, this)); + thread_pool_.AddTask(boost::bind(&NameServerImpl::UpdateRealEpMapToTablet, this, true)); } void NameServerImpl::OnTabletOffline(const std::string& endpoint, bool startup_flag) { @@ -9651,8 +9652,8 @@ void NameServerImpl::SetSdkEndpoint(RpcController* controller, const SetSdkEndpo response->set_msg("ok"); } -void NameServerImpl::UpdateRealEpMapToTablet() { - if (!running_.load(std::memory_order_acquire)) { +void NameServerImpl::UpdateRealEpMapToTablet(bool check_running) { + if (check_running && !running_.load(std::memory_order_acquire)) { return; } decltype(tablets_) tmp_tablets; @@ -9727,7 +9728,7 @@ void NameServerImpl::UpdateRemoteRealEpMap() { remote_real_ep_map_.swap(tmp_map); } if (old_map != tmp_map) { - thread_pool_.AddTask(boost::bind(&NameServerImpl::UpdateRealEpMapToTablet, this)); + thread_pool_.AddTask(boost::bind(&NameServerImpl::UpdateRealEpMapToTablet, this, true)); } } while (false); task_thread_pool_.DelayTask(FLAGS_get_replica_status_interval, diff --git a/src/nameserver/name_server_impl.h b/src/nameserver/name_server_impl.h index 910c642dfa6..fedfcaa0465 100644 --- a/src/nameserver/name_server_impl.h +++ b/src/nameserver/name_server_impl.h @@ -720,7 +720,7 @@ class NameServerImpl : public NameServer { const std::map>& table_info_map, const std::unordered_map& pos_response); - void UpdateRealEpMapToTablet(); + void UpdateRealEpMapToTablet(bool check_running); void UpdateRemoteRealEpMap(); diff --git a/src/tablet/tablet_impl.cc b/src/tablet/tablet_impl.cc index b6b8e0c264c..bf96bbc14e8 100644 --- a/src/tablet/tablet_impl.cc +++ b/src/tablet/tablet_impl.cc @@ -4711,6 +4711,9 @@ void TabletImpl::UpdateRealEndpointMap(RpcController* controller, } std::atomic_store_explicit(&real_ep_map_, tmp_real_ep_map, std::memory_order_release); DLOG(INFO) << "real_ep_map size is " << tmp_real_ep_map->size(); + for (const auto& kv : *tmp_real_ep_map) { + LOG(INFO) << "update real endpoint: " << kv.first << " : " << kv.second; + } catalog_->UpdateClient(*tmp_real_ep_map); response->set_code(::openmldb::base::ReturnCode::kOk); response->set_msg("ok");