fix clog replay 4725 error

This commit is contained in:
hiddenbomb
2023-07-10 03:47:37 +00:00
committed by ob-robot
parent 2647aaccd3
commit 0bebe6cec9
3 changed files with 37 additions and 12 deletions

View File

@ -1442,9 +1442,10 @@ int ObLS::finish_slog_replay()
return ret;
}
int ObLS::replay_get_tablet_no_check(const common::ObTabletID &tablet_id,
const SCN &scn,
ObTabletHandle &handle) const
int ObLS::replay_get_tablet_no_check(
const common::ObTabletID &tablet_id,
const SCN &scn,
ObTabletHandle &handle) const
{
int ret = OB_SUCCESS;
const ObTabletMapKey key(ls_meta_.ls_id_, tablet_id);
@ -1495,19 +1496,23 @@ int ObLS::replay_get_tablet_no_check(const common::ObTabletID &tablet_id,
return ret;
}
int ObLS::replay_get_tablet(const common::ObTabletID &tablet_id,
const SCN &scn,
ObTabletHandle &handle) const
int ObLS::replay_get_tablet(
const common::ObTabletID &tablet_id,
const SCN &scn,
ObTabletHandle &handle) const
{
int ret = OB_SUCCESS;
const share::ObLSID &ls_id = ls_meta_.ls_id_;
ObTabletHandle tablet_handle;
ObTablet *tablet = nullptr;
ObTabletCreateDeleteMdsUserData data;
bool is_committed = false;
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))) {
LOG_WARN("failed to get tablet", K(ret), K(tablet_id), K(ls_meta_.ls_id_));
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
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())) {
@ -1515,8 +1520,6 @@ int ObLS::replay_get_tablet(const common::ObTabletID &tablet_id,
LOG_WARN("tablet should not be NULL", K(ret), KP(tablet), K(tablet_id), K(scn));
} else if (tablet->is_empty_shell()) {
ObTabletStatus::Status tablet_status = ObTabletStatus::MAX;
ObTabletCreateDeleteMdsUserData data;
bool is_committed = false;
if (OB_FAIL(tablet->get_latest_tablet_status(data, is_committed))) {
LOG_WARN("failed to get latest tablet status", K(ret), KPC(tablet));
} else if (!is_committed) {
@ -1529,9 +1532,26 @@ int ObLS::replay_get_tablet(const common::ObTabletID &tablet_id,
LOG_WARN("tablet is empty shell but user data is unexpected", K(ret), KPC(tablet));
} else {
ret = OB_OBSOLETE_CLOG_NEED_SKIP;
LOG_INFO("tablet is already deleted, need skip", KR(ret), K(tablet_id), K(ls_meta_.ls_id_), K(scn));
LOG_INFO("tablet is already deleted, need skip", KR(ret), K(ls_id), K(tablet_id), K(scn));
}
} else if (scn > tablet->get_clog_checkpoint_scn()) {
if (OB_FAIL(tablet->get_latest_tablet_status(data, is_committed))) {
if (OB_EMPTY_RESULT == ret) {
ret = OB_EAGAIN;
LOG_INFO("read empty mds data, should retry", KR(ret), K(ls_id), K(tablet_id), K(scn));
} else {
LOG_WARN("failed to get latest tablet status", K(ret), KPC(tablet));
}
} else if (!is_committed) {
if ((ObTabletStatus::NORMAL == data.tablet_status_ && data.create_commit_version_ == ObTransVersion::INVALID_TRANS_VERSION)
|| ObTabletStatus::TRANSFER_IN == data.tablet_status_) {
ret = OB_EAGAIN;
LOG_INFO("latest transaction has not committed yet, should retry", KR(ret), K(ls_id), K(tablet_id),
K(scn), "clog_checkpoint_scn", tablet->get_clog_checkpoint_scn(), K(data));
}
}
}
if (OB_SUCC(ret)) {
handle = tablet_handle;
}

View File

@ -117,13 +117,16 @@ 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(tablet_id, replay_scn, handle))) {
if (OB_FAIL(ls.replay_get_tablet_no_check(tablet_id, replay_scn, handle))) {
if (OB_OBSOLETE_CLOG_NEED_SKIP == ret) {
ret = OB_NO_NEED_UPDATE;
LOG_WARN("clog is obsolete, should skip replay", K(ret));
} else {
LOG_WARN("failed to get tablet", K(ret));
}
} else if (OB_UNLIKELY(handle.get_obj()->is_empty_shell())) {
ret = OB_NO_NEED_UPDATE;
LOG_WARN("tablet is already deleted, need skip", K(ret), K(key));
}
} else if (OB_FAIL(ObTabletCreateDeleteHelper::get_tablet(key, handle))) {
LOG_WARN("failed to get tablet", K(ret), K(key));

View File

@ -37,7 +37,9 @@ public:
protected:
bool is_replay_update_tablet_status_() const override
{
return false;
// TODO (jiahua.cjh): binding is pre barrier that doesn't
// need call ObLS::replay_get_tablet. Consider refactor base execuator interface
return true;
}
int do_replay_(ObTabletHandle &tablet_handle) override;