From ad9abcc7a49d3895af0bbfd56683522243f1f54b Mon Sep 17 00:00:00 2001 From: hamstersox <673144759@qq.com> Date: Fri, 16 Dec 2022 13:07:54 +0000 Subject: [PATCH] fix no delivery proposal_id in notify_restore_tablets --- src/storage/ob_storage_rpc.cpp | 22 ++++++++++--------- src/storage/ob_storage_rpc.h | 10 +++++---- src/storage/restore/ob_ls_restore_handler.cpp | 7 +++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/storage/ob_storage_rpc.cpp b/src/storage/ob_storage_rpc.cpp index 0aadf8179..6f635fc31 100644 --- a/src/storage/ob_storage_rpc.cpp +++ b/src/storage/ob_storage_rpc.cpp @@ -1551,7 +1551,7 @@ int ObInquireRestoreP::process() int64_t disk_abnormal_time = 0; bool is_follower = false; - LOG_INFO("start to inquire leader restore", K(arg_)); + LOG_INFO("start to inquire restore status", K(arg_)); #ifdef ERRSIM if (OB_SUCC(ret) && DEVICE_HEALTH_NORMAL == dhs && GCONF.fake_disk_error) { @@ -1582,13 +1582,13 @@ int ObInquireRestoreP::process() LOG_WARN("log srv should not be null", K(ret), KP(log_srv)); } else if (OB_FAIL(is_follower_ls(log_srv, ls, is_follower))) { LOG_WARN("failed to check is follower", K(ret), KP(ls), K(arg_)); + } else if (OB_FAIL(ls->get_restore_status(result_.restore_status_))) { + LOG_WARN("fail to get restore status", K(ret)); } else if (is_follower) { result_.tenant_id_ = arg_.tenant_id_; result_.ls_id_ = arg_.ls_id_; result_.is_leader_ = false; - LOG_INFO("ls may switch leader", K(result_)); - } else if (OB_FAIL(ls->get_restore_status(result_.restore_status_))) { - LOG_WARN("fail to get restore status", K(ret)); + LOG_INFO("succ to inquire restore status from follower", K(result_)); } else { result_.tenant_id_ = arg_.tenant_id_; result_.ls_id_ = arg_.ls_id_; @@ -1800,6 +1800,7 @@ int ObStorageRpc::notify_restore_tablets( const uint64_t tenant_id, const ObStorageHASrcInfo &follower_info, const share::ObLSID &ls_id, + const int64_t &proposal_id, const common::ObIArray& tablet_id_array, const share::ObLSRestoreStatus &restore_status, obrpc::ObNotifyRestoreTabletsResp &restore_resp) @@ -1819,6 +1820,7 @@ int ObStorageRpc::notify_restore_tablets( arg.tenant_id_ = tenant_id; arg.ls_id_ = ls_id; arg.restore_status_ = restore_status; + arg.leader_proposal_id_ = proposal_id; if (OB_FAIL(rpc_proxy_->to(follower_info.src_addr_).dst_cluster_id(follower_info.cluster_id_).notify_restore_tablets(arg, restore_resp))) { LOG_WARN("failed to notify follower restore tablets", K(ret), K(arg), K(follower_info), K(ls_id), K(tablet_id_array)); } else { @@ -1830,7 +1832,7 @@ int ObStorageRpc::notify_restore_tablets( int ObStorageRpc::inquire_restore( const uint64_t tenant_id, - const ObStorageHASrcInfo &leader_info, + const ObStorageHASrcInfo &src_info, const share::ObLSID &ls_id, const share::ObLSRestoreStatus &restore_status, obrpc::ObInquireRestoreResp &restore_resp) @@ -1839,18 +1841,18 @@ int ObStorageRpc::inquire_restore( if (!is_inited_) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "storage rpc is not inited", K(ret)); - } else if (!leader_info.is_valid() || !ls_id.is_valid()) { + } else if (!src_info.is_valid() || !ls_id.is_valid()) { ret = OB_INVALID_ARGUMENT; - STORAGE_LOG(WARN, "inquire leader restore get invalid argument", K(ret), K(leader_info), K(ls_id)); + STORAGE_LOG(WARN, "inquire restore get invalid argument", K(ret), K(src_info), K(ls_id)); } else { ObInquireRestoreArg arg; arg.tenant_id_ = tenant_id; arg.ls_id_ = ls_id; arg.restore_status_ = restore_status; - if (OB_FAIL(rpc_proxy_->to(leader_info.src_addr_).dst_cluster_id(leader_info.cluster_id_).inquire_restore(arg, restore_resp))) { - LOG_WARN("failed to inquire restore", K(ret), K(arg), K(leader_info)); + if (OB_FAIL(rpc_proxy_->to(src_info.src_addr_).dst_cluster_id(src_info.cluster_id_).inquire_restore(arg, restore_resp))) { + LOG_WARN("failed to inquire restore", K(ret), K(arg), K(src_info)); } else { - FLOG_INFO("inquire leader restore successfully", K(arg), K(leader_info)); + FLOG_INFO("inquire restore status successfully", K(arg), K(src_info)); } } return ret; diff --git a/src/storage/ob_storage_rpc.h b/src/storage/ob_storage_rpc.h index 383dea960..dcfe42a29 100644 --- a/src/storage/ob_storage_rpc.h +++ b/src/storage/ob_storage_rpc.h @@ -612,14 +612,15 @@ public: const uint64_t tenant_id, const ObStorageHASrcInfo &follower_info, const share::ObLSID &ls_id, + const int64_t &proposal_id, const common::ObIArray& tablet_id_array, const share::ObLSRestoreStatus &restore_status, obrpc::ObNotifyRestoreTabletsResp &restore_resp) = 0; - // Notify follower restore from leader. + // inquire restore status from src. virtual int inquire_restore( const uint64_t tenant_id, - const ObStorageHASrcInfo &leader_info, + const ObStorageHASrcInfo &src_info, const share::ObLSID &ls_id, const share::ObLSRestoreStatus &restore_status, obrpc::ObInquireRestoreResp &restore_resp) = 0; @@ -662,14 +663,15 @@ public: const uint64_t tenant_id, const ObStorageHASrcInfo &follower_info, const share::ObLSID &ls_id, + const int64_t &proposal_id, const common::ObIArray& tablet_id_array, const share::ObLSRestoreStatus &restore_status, obrpc::ObNotifyRestoreTabletsResp &restore_resp); - // Notify follower restore from leader. + // inquire restore status from src. virtual int inquire_restore( const uint64_t tenant_id, - const ObStorageHASrcInfo &follower_info, + const ObStorageHASrcInfo &src_info, const share::ObLSID &ls_id, const share::ObLSRestoreStatus &restore_status, obrpc::ObInquireRestoreResp &restore_resp); diff --git a/src/storage/restore/ob_ls_restore_handler.cpp b/src/storage/restore/ob_ls_restore_handler.cpp index 24e28a817..22fc9d6e3 100644 --- a/src/storage/restore/ob_ls_restore_handler.cpp +++ b/src/storage/restore/ob_ls_restore_handler.cpp @@ -1145,7 +1145,7 @@ int ObILSRestoreState::notify_follower_restore_tablet_(const ObIArraynotify_restore_tablets(ls_restore_arg_->get_tenant_id(), follower_info, ls_->get_ls_id(), - tablet_ids, ls_restore_status_, restore_resp))) { + proposal_id_, tablet_ids, ls_restore_status_, restore_resp))) { LOG_WARN("fail to notify follower restore tablets", K(ret), K(follower_info), K(tablet_ids), KPC(ls_)); } } @@ -1185,7 +1185,7 @@ int ObILSRestoreState::request_follower_restore_status_(bool &finish) ObArray follower; ObLSService *ls_service = nullptr; ObStorageRpc *storage_rpc = nullptr; - obrpc::ObNotifyRestoreTabletsResp restore_resp; + obrpc::ObInquireRestoreResp restore_resp; finish = true; ObArray tablet_ids; if (OB_ISNULL(ls_service = (MTL(ObLSService *)))) { @@ -1201,7 +1201,8 @@ int ObILSRestoreState::request_follower_restore_status_(bool &finish) for (int64_t i = 0; OB_SUCC(ret) && i < follower.count(); ++i) { const ObStorageHASrcInfo &follower_info = follower.at(i); is_finish = false; - if (OB_FAIL(storage_rpc->notify_restore_tablets(ls_restore_arg_->get_tenant_id(), follower_info, ls_->get_ls_id(), tablet_ids, ls_restore_status_, restore_resp))) { + if (OB_FAIL(storage_rpc->inquire_restore(ls_restore_arg_->get_tenant_id(), follower_info, ls_->get_ls_id(), + ls_restore_status_, restore_resp))) { LOG_WARN("fail to inquire restore status", K(ret), K(follower_info), K(tablet_ids), KPC(ls_)); } else if (OB_FAIL(check_follower_restore_finish(ls_restore_status_, restore_resp.restore_status_, is_finish))) { LOG_WARN("fail to check follower restore finish", K(ret), KPC(ls_), K(ls_restore_status_), K(restore_resp));