From 12d8b47370e08fb9be953dfe62ca7ba51a09fdbc Mon Sep 17 00:00:00 2001 From: godyangfight Date: Tue, 2 Apr 2024 05:12:00 +0000 Subject: [PATCH] Fix replay finish transfer in log allow tablet not exist bug. --- .../replayservice/ob_tablet_replay_executor.cpp | 3 ++- src/logservice/replayservice/ob_tablet_replay_executor.h | 2 ++ src/storage/ddl/ob_ddl_replay_executor.cpp | 8 ++++++-- src/storage/ls/ob_ls.cpp | 9 ++++++--- src/storage/ls/ob_ls.h | 1 + src/storage/tablet/ob_tablet_binding_helper.cpp | 3 ++- .../tablet/ob_tablet_finish_transfer_mds_helper.cpp | 3 +++ .../tablet/ob_tablet_start_transfer_mds_helper.cpp | 2 ++ 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/logservice/replayservice/ob_tablet_replay_executor.cpp b/src/logservice/replayservice/ob_tablet_replay_executor.cpp index 71b0bcf57b..f8b54de2a1 100644 --- a/src/logservice/replayservice/ob_tablet_replay_executor.cpp +++ b/src/logservice/replayservice/ob_tablet_replay_executor.cpp @@ -132,7 +132,8 @@ int ObTabletReplayExecutor::replay_get_tablet_( } else { const share::ObLSID &ls_id = ls->get_ls_id(); if (is_replay_update_tablet_status_()) { - if (OB_FAIL(ls->replay_get_tablet_no_check(tablet_id, scn, tablet_handle))) { + const bool allow_tablet_not_exist = replay_allow_tablet_not_exist_(); + if (OB_FAIL(ls->replay_get_tablet_no_check(tablet_id, scn, allow_tablet_not_exist, tablet_handle))) { CLOG_LOG(WARN, "replay get table failed", KR(ret), K(ls_id), K(tablet_id)); } } else if (OB_FAIL(ls->replay_get_tablet(tablet_id, scn, is_update_mds_table, tablet_handle))) { diff --git a/src/logservice/replayservice/ob_tablet_replay_executor.h b/src/logservice/replayservice/ob_tablet_replay_executor.h index 196a228283..357456d98a 100644 --- a/src/logservice/replayservice/ob_tablet_replay_executor.h +++ b/src/logservice/replayservice/ob_tablet_replay_executor.h @@ -91,6 +91,8 @@ protected: // @return other error codes, failed to replay. virtual int replay_check_restore_status_(storage::ObTabletHandle &tablet_handle); + virtual bool replay_allow_tablet_not_exist_() { return true; } + // not allowed to pass ObTabletCreateDeleteMdsUserData or ObTabletBindingMdsUserData template replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) { + const bool replay_allow_tablet_not_exist = true; + if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, + replay_allow_tablet_not_exist, lob_meta_tablet_handle))) { LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_)); } else if (OB_FAIL(replay_ddl_start(lob_meta_tablet_handle, true/*is_lob_meta_tablet*/))) { LOG_WARN("replay ddl start for lob meta tablet failed", K(ret), K(lob_meta_tablet_id), K(scn_)); @@ -423,7 +425,9 @@ int ObDDLCommitReplayExecutor::do_replay_(ObTabletHandle &tablet_handle) LOG_WARN("get lob meta tablet id failed", K(ret)); } else if (lob_meta_tablet_id.is_valid()) { ObTabletHandle lob_meta_tablet_handle; - if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) { + const bool replay_allow_tablet_not_exist = true; + if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, + replay_allow_tablet_not_exist, lob_meta_tablet_handle))) { LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_)); } else if (OB_FAIL(replay_ddl_commit(lob_meta_tablet_handle))) { LOG_WARN("replay ddl start for lob meta tablet failed", K(ret), K(lob_meta_tablet_id), K(scn_)); diff --git a/src/storage/ls/ob_ls.cpp b/src/storage/ls/ob_ls.cpp index a5cd0edfb1..9d8f6314c3 100644 --- a/src/storage/ls/ob_ls.cpp +++ b/src/storage/ls/ob_ls.cpp @@ -1694,6 +1694,7 @@ int ObLS::finish_slog_replay() int ObLS::replay_get_tablet_no_check( const common::ObTabletID &tablet_id, const SCN &scn, + const bool replay_allow_tablet_not_exist, ObTabletHandle &handle) const { int ret = OB_SUCCESS; @@ -1727,9 +1728,10 @@ int ObLS::replay_get_tablet_no_check( } else if (!max_scn.is_valid()) { ret = OB_ERR_UNEXPECTED; LOG_WARN("max_scn is invalid", KR(ret), K(key), K(scn), K(tablet_change_checkpoint_scn)); - } else if (scn > SCN::scn_inc(max_scn)) { + } else if (scn > SCN::scn_inc(max_scn) || !replay_allow_tablet_not_exist) { ret = OB_EAGAIN; - LOG_INFO("tablet does not exist, but need retry", KR(ret), K(key), K(scn), K(tablet_change_checkpoint_scn), K(max_scn)); + LOG_INFO("tablet does not exist, but need retry", KR(ret), K(key), K(scn), + K(tablet_change_checkpoint_scn), K(max_scn), K(replay_allow_tablet_not_exist)); } else { ret = OB_OBSOLETE_CLOG_NEED_SKIP; LOG_INFO("tablet already gc, but scn is more than tablet_change_checkpoint_scn", KR(ret), @@ -1757,11 +1759,12 @@ int ObLS::replay_get_tablet( ObTablet *tablet = nullptr; ObTabletCreateDeleteMdsUserData data; bool is_committed = false; + const bool replay_allow_tablet_not_exist = true; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("ls is not inited", KR(ret)); - } else if (OB_FAIL(replay_get_tablet_no_check(tablet_id, scn, tablet_handle))) { + } else if (OB_FAIL(replay_get_tablet_no_check(tablet_id, scn, replay_allow_tablet_not_exist, tablet_handle))) { LOG_WARN("failed to get tablet", K(ret), K(ls_id), K(tablet_id), K(scn)); } else if (tablet_id.is_ls_inner_tablet()) { // do nothing diff --git a/src/storage/ls/ob_ls.h b/src/storage/ls/ob_ls.h index fe277a3752..ef2a66019d 100644 --- a/src/storage/ls/ob_ls.h +++ b/src/storage/ls/ob_ls.h @@ -380,6 +380,7 @@ public: int replay_get_tablet_no_check( const common::ObTabletID &tablet_id, const share::SCN &scn, + const bool replay_allow_tablet_not_exist, ObTabletHandle &tablet_handle) const; int flush_if_need(const bool need_flush); diff --git a/src/storage/tablet/ob_tablet_binding_helper.cpp b/src/storage/tablet/ob_tablet_binding_helper.cpp index 0a4637e8fd..88163bfc30 100644 --- a/src/storage/tablet/ob_tablet_binding_helper.cpp +++ b/src/storage/tablet/ob_tablet_binding_helper.cpp @@ -175,7 +175,8 @@ int ObTabletBindingHelper::get_tablet_for_new_mds(const ObLS &ls, const ObTablet const ObTabletMapKey key(ls.get_ls_id(), tablet_id); const bool for_replay = replay_scn.is_valid(); if (for_replay) { - if (OB_FAIL(ls.replay_get_tablet_no_check(tablet_id, replay_scn, handle))) { + const bool replay_allow_tablet_not_exist = true; + if (OB_FAIL(ls.replay_get_tablet_no_check(tablet_id, replay_scn, replay_allow_tablet_not_exist, handle))) { if (OB_OBSOLETE_CLOG_NEED_SKIP == ret) { ret = OB_NO_NEED_UPDATE; LOG_WARN("clog is obsolete, should skip replay", K(ret)); diff --git a/src/storage/tablet/ob_tablet_finish_transfer_mds_helper.cpp b/src/storage/tablet/ob_tablet_finish_transfer_mds_helper.cpp index ccc8899176..eef3f2cfa5 100644 --- a/src/storage/tablet/ob_tablet_finish_transfer_mds_helper.cpp +++ b/src/storage/tablet/ob_tablet_finish_transfer_mds_helper.cpp @@ -148,6 +148,8 @@ protected: return true; } + virtual bool replay_allow_tablet_not_exist_() { return false; } + private: int check_src_transfer_tablet_(ObTabletHandle &tablet_handle); @@ -585,6 +587,7 @@ protected: { return true; } + virtual bool replay_allow_tablet_not_exist_() { return false; } private: int check_dest_transfer_tablet_(ObTabletHandle &tablet_handle); diff --git a/src/storage/tablet/ob_tablet_start_transfer_mds_helper.cpp b/src/storage/tablet/ob_tablet_start_transfer_mds_helper.cpp index ebacbb5786..7d516d4171 100644 --- a/src/storage/tablet/ob_tablet_start_transfer_mds_helper.cpp +++ b/src/storage/tablet/ob_tablet_start_transfer_mds_helper.cpp @@ -68,6 +68,8 @@ protected: return true; } + virtual bool replay_allow_tablet_not_exist_() { return false; } + private: int check_src_transfer_tablet_(ObTabletHandle &tablet_handle);