提交 302ae680 编写于 作者: qq_43633081's avatar qq_43633081 提交者: ob-robot

forbid scheduling deleted tablet to do restore

上级 7d436f68
...@@ -591,6 +591,24 @@ int ObLSRestoreHandler::check_tablet_restore_finish_( ...@@ -591,6 +591,24 @@ int ObLSRestoreHandler::check_tablet_restore_finish_(
return ret; return ret;
} }
int ObLSRestoreHandler::check_tablet_deleted(const ObTabletHandle &tablet_handle, bool &is_deleted)
{
int ret = OB_SUCCESS;
// TODO(chongrong.th) need to think about transfer out deleted in 4.2
is_deleted = false;
ObTabletStatus::Status tablet_status = ObTabletStatus::Status::MAX;
if (!tablet_handle.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tablet handle", K(ret));
} else if (OB_FAIL(tablet_handle.get_obj()->get_tablet_status(tablet_status))) {
LOG_WARN("failed to get tablet status", K(ret));
} else if (ObTabletStatus::Status::DELETED == tablet_status) {
is_deleted = true;
const ObTabletID tablet_id = tablet_handle.get_obj()->get_tablet_meta().tablet_id_;
LOG_INFO("tablet deleted", K(tablet_id), K(tablet_status));
}
return ret;
}
void ObLSRestoreHandler::wakeup() void ObLSRestoreHandler::wakeup()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
...@@ -983,6 +1001,7 @@ int ObILSRestoreState::reload_tablet_() ...@@ -983,6 +1001,7 @@ int ObILSRestoreState::reload_tablet_()
} }
while (OB_SUCC(ret)) { while (OB_SUCC(ret)) {
bool is_deleted = false;
if (OB_FAIL(iterator.get_next_tablet(tablet_handle))) { if (OB_FAIL(iterator.get_next_tablet(tablet_handle))) {
if (OB_ITER_END == ret) { if (OB_ITER_END == ret) {
ret = OB_SUCCESS; ret = OB_SUCCESS;
...@@ -990,6 +1009,9 @@ int ObILSRestoreState::reload_tablet_() ...@@ -990,6 +1009,9 @@ int ObILSRestoreState::reload_tablet_()
} else { } else {
LOG_WARN("fail to get next tablet", K(ret)); LOG_WARN("fail to get next tablet", K(ret));
} }
} else if (OB_FAIL(ObLSRestoreHandler::check_tablet_deleted(tablet_handle, is_deleted))) {
LOG_WARN("failed to check tablet need schedule restore", K(ret), K(tablet_handle));
} else if (is_deleted) {
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())) { } else if (OB_ISNULL(tablet = tablet_handle.get_obj())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("tablet is nullptr", K(ret)); LOG_WARN("tablet is nullptr", K(ret));
...@@ -1082,6 +1104,7 @@ int ObILSRestoreState::upload_wait_restore_tablet_() ...@@ -1082,6 +1104,7 @@ int ObILSRestoreState::upload_wait_restore_tablet_()
bool is_finish = false; bool is_finish = false;
while (OB_SUCC(ret)) { while (OB_SUCC(ret)) {
is_finish = false; is_finish = false;
bool is_deleted = false;
if (OB_FAIL(iterator.get_next_tablet(tablet_handle))) { if (OB_FAIL(iterator.get_next_tablet(tablet_handle))) {
if (OB_ITER_END == ret) { if (OB_ITER_END == ret) {
ret = OB_SUCCESS; ret = OB_SUCCESS;
...@@ -1089,6 +1112,9 @@ int ObILSRestoreState::upload_wait_restore_tablet_() ...@@ -1089,6 +1112,9 @@ int ObILSRestoreState::upload_wait_restore_tablet_()
} else { } else {
LOG_WARN("fail to get next tablet", K(ret)); LOG_WARN("fail to get next tablet", K(ret));
} }
} else if (OB_FAIL(ObLSRestoreHandler::check_tablet_deleted(tablet_handle, is_deleted))) {
LOG_WARN("failed to check tablet need schedule restore", K(ret), K(tablet_handle));
} else if (is_deleted) {
} else if (nullptr == (tablet = tablet_handle.get_obj())) { } else if (nullptr == (tablet = tablet_handle.get_obj())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("tablet is nullptr", K(ret)); LOG_WARN("tablet is nullptr", K(ret));
......
...@@ -85,6 +85,7 @@ public: ...@@ -85,6 +85,7 @@ public:
const share::ObLSRestoreStatus &leader_restore_status, const int64_t leader_proposal_id); const share::ObLSRestoreStatus &leader_restore_status, const int64_t leader_proposal_id);
static int check_tablet_restore_finish_(const share::ObLSRestoreStatus &ls_restore_status, static int check_tablet_restore_finish_(const share::ObLSRestoreStatus &ls_restore_status,
const ObTabletMeta &tablet_meta, bool &is_finish); const ObTabletMeta &tablet_meta, bool &is_finish);
static int check_tablet_deleted(const ObTabletHandle &tablet_handle, bool &is_deleted);
void wakeup(); void wakeup();
void stop() { ATOMIC_STORE(&is_stop_, true); } // when remove ls, set this void stop() { ATOMIC_STORE(&is_stop_, true); } // when remove ls, set this
int safe_to_destroy(bool &is_safe); int safe_to_destroy(bool &is_safe);
......
...@@ -392,6 +392,9 @@ int ObLSRestoreTaskMgr::check_tablet_deleted_or_restored_(storage::ObLS &ls, con ...@@ -392,6 +392,9 @@ int ObLSRestoreTaskMgr::check_tablet_deleted_or_restored_(storage::ObLS &ls, con
} else if (nullptr == (tablet = tablet_handle.get_obj())) { } else if (nullptr == (tablet = tablet_handle.get_obj())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("nullptr tablet", K(ret)); LOG_WARN("nullptr tablet", K(ret));
} else if (OB_FAIL(ObLSRestoreHandler::check_tablet_deleted(tablet_handle, is_deleted))) {
LOG_WARN("failed to check tablet deleted", K(ret), K(tablet_handle));
} else if (is_deleted) { // do nothing
} else { } else {
const ObTabletMeta &tablet_meta = tablet->get_tablet_meta(); const ObTabletMeta &tablet_meta = tablet->get_tablet_meta();
if (OB_FAIL(ObLSRestoreHandler::check_tablet_restore_finish_(ls_restore_status, tablet_meta, is_restored))) { if (OB_FAIL(ObLSRestoreHandler::check_tablet_restore_finish_(ls_restore_status, tablet_meta, is_restored))) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册