filter the non-exist tablet by replay_get_tablet for replaying delete tablet clog when ob is updated from 4.1 to 4.2

This commit is contained in:
obdev
2023-06-29 02:49:06 +00:00
committed by ob-robot
parent 348bb57bac
commit f273041da8
14 changed files with 166 additions and 71 deletions

View File

@ -200,7 +200,8 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletCreateDeleteMdsUserData &mds, const ObTabletCreateDeleteMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
storage::ObTablet *tablet = tablet_handle.get_obj(); storage::ObTablet *tablet = tablet_handle.get_obj();
@ -224,10 +225,16 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
} else if (OB_ISNULL(ls = ls_handle.get_ls())) { } else if (OB_ISNULL(ls = ls_handle.get_ls())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
CLOG_LOG(WARN, "ls is null", K(ret), K(ls_id), KP(ls)); CLOG_LOG(WARN, "ls is null", K(ret), K(ls_id), KP(ls));
} else if (OB_FAIL(ls->get_tablet_svr()->replay_set_tablet_status(tablet_id, scn, mds, ctx))) { } else if (for_old_mds) {
if (OB_FAIL(ls->get_tablet_svr()->set_tablet_status(tablet_id, mds, ctx))) {
CLOG_LOG(WARN, "failed to set mds data", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds));
}
} else {
if (OB_FAIL(ls->get_tablet_svr()->replay_set_tablet_status(tablet_id, scn, mds, ctx))) {
CLOG_LOG(WARN, "failed to replay set tablet status", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds)); CLOG_LOG(WARN, "failed to replay set tablet status", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds));
} }
} }
}
return ret; return ret;
} }
@ -235,7 +242,8 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletBindingMdsUserData &mds, const ObTabletBindingMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
storage::ObTablet *tablet = tablet_handle.get_obj(); storage::ObTablet *tablet = tablet_handle.get_obj();
@ -259,10 +267,16 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
} else if (OB_ISNULL(ls = ls_handle.get_ls())) { } else if (OB_ISNULL(ls = ls_handle.get_ls())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
CLOG_LOG(WARN, "ls is null", K(ret), K(ls_id), KP(ls)); CLOG_LOG(WARN, "ls is null", K(ret), K(ls_id), KP(ls));
} else if (OB_FAIL(ls->get_tablet_svr()->replay_set_ddl_info(tablet_id, scn, mds, ctx))) { } else if (for_old_mds) {
if (OB_FAIL(ls->get_tablet_svr()->set_ddl_info(tablet_id, mds, ctx, 0))) {
CLOG_LOG(WARN, "failed to save tablet binding info", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds));
}
} else {
if (OB_FAIL(ls->get_tablet_svr()->replay_set_ddl_info(tablet_id, scn, mds, ctx))) {
CLOG_LOG(WARN, "failed to replay set ddl info", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds)); CLOG_LOG(WARN, "failed to replay set ddl info", K(ret), K(ls_id), K(tablet_id), K(scn), K(mds));
} }
} }
}
return ret; return ret;
} }

View File

@ -108,12 +108,14 @@ protected:
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletCreateDeleteMdsUserData &mds, const ObTabletCreateDeleteMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn); const share::SCN &scn,
const bool for_old_mds = false);
int replay_to_mds_table_( int replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletBindingMdsUserData &mds, const ObTabletBindingMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn); const share::SCN &scn,
const bool for_old_mds = false);
template <typename K, typename V> template <typename K, typename V>
int replay_to_mds_table_( int replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,

View File

@ -157,7 +157,7 @@ int ObTabletBindingHelper::modify_tablet_binding_for_new_mds_create(const ObBatc
for (int64_t i = 0; OB_SUCC(ret) && i < arg.tablets_.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < arg.tablets_.count(); i++) {
const ObCreateTabletInfo &info = arg.tablets_[i]; const ObCreateTabletInfo &info = arg.tablets_[i];
if (ObTabletCreateDeleteHelper::is_pure_hidden_tablets(info)) { if (ObTabletCreateDeleteHelper::is_pure_hidden_tablets(info)) {
if (CLICK_FAIL(bind_hidden_tablet_to_orig_tablet(ls, info, replay_scn, ctx))) { if (CLICK_FAIL(bind_hidden_tablet_to_orig_tablet(ls, info, replay_scn, ctx, arg.is_old_mds_))) {
LOG_WARN("failed to add hidden tablet", K(ret)); LOG_WARN("failed to add hidden tablet", K(ret));
} }
} else if (ObTabletBindingHelper::has_lob_tablets(arg, info)) { } else if (ObTabletBindingHelper::has_lob_tablets(arg, info)) {
@ -174,9 +174,10 @@ int ObTabletBindingHelper::bind_hidden_tablet_to_orig_tablet(
ObLS &ls, ObLS &ls,
const ObCreateTabletInfo &info, const ObCreateTabletInfo &info,
const share::SCN &replay_scn, const share::SCN &replay_scn,
mds::BufferCtx &ctx) mds::BufferCtx &ctx,
const bool for_old_mds)
{ {
return modify_tablet_binding_new_mds(ls, info.data_tablet_id_, replay_scn, ctx, [&info](ObTabletBindingMdsUserData &data) -> int { return modify_tablet_binding_new_mds(ls, info.data_tablet_id_, replay_scn, ctx, for_old_mds, [&info](ObTabletBindingMdsUserData &data) -> int {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const ObTabletID &orig_tablet_id = info.data_tablet_id_; const ObTabletID &orig_tablet_id = info.data_tablet_id_;
for (int64_t i = 0; OB_SUCC(ret) && i < info.tablet_ids_.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < info.tablet_ids_.count(); i++) {
@ -196,7 +197,7 @@ int ObTabletBindingHelper::bind_lob_tablet_to_data_tablet(
const share::SCN &replay_scn, const share::SCN &replay_scn,
mds::BufferCtx &ctx) mds::BufferCtx &ctx)
{ {
return modify_tablet_binding_new_mds(ls, info.data_tablet_id_, replay_scn, ctx, [&arg, &info](ObTabletBindingMdsUserData &data) -> int { return modify_tablet_binding_new_mds(ls, info.data_tablet_id_, replay_scn, ctx, arg.is_old_mds_, [&arg, &info](ObTabletBindingMdsUserData &data) -> int {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const ObTabletID &data_tablet_id = info.data_tablet_id_; const ObTabletID &data_tablet_id = info.data_tablet_id_;
for (int64_t i = 0; OB_SUCC(ret) && i < info.tablet_ids_.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < info.tablet_ids_.count(); i++) {
@ -222,6 +223,7 @@ int ObTabletBindingHelper::modify_tablet_binding_new_mds(
const ObTabletID &tablet_id, const ObTabletID &tablet_id,
const share::SCN &replay_scn, const share::SCN &replay_scn,
mds::BufferCtx &ctx, mds::BufferCtx &ctx,
bool for_old_mds,
F op) F op)
{ {
MDS_TG(100_ms); MDS_TG(100_ms);
@ -244,7 +246,7 @@ int ObTabletBindingHelper::modify_tablet_binding_new_mds(
} else { } else {
if (replay_scn.is_valid()) { if (replay_scn.is_valid()) {
ObTabletBindingReplayExecutor replay_executor; ObTabletBindingReplayExecutor replay_executor;
if (CLICK_FAIL(replay_executor.init(ctx, data, replay_scn))) { if (CLICK_FAIL(replay_executor.init(ctx, data, replay_scn, for_old_mds))) {
LOG_WARN("failed to init replay executor", K(ret)); LOG_WARN("failed to init replay executor", K(ret));
} else if (CLICK_FAIL(replay_executor.execute(replay_scn, ls.get_ls_id(), tablet_id))) { } else if (CLICK_FAIL(replay_executor.execute(replay_scn, ls.get_ls_id(), tablet_id))) {
if (OB_EAGAIN != ret) { if (OB_EAGAIN != ret) {
@ -299,6 +301,22 @@ int ObTabletUnbindMdsHelper::on_register(const char* buf, const int64_t len, mds
return ret; return ret;
} }
int ObTabletUnbindMdsHelper::replay_process(
ObBatchUnbindTabletArg &arg,
const share::SCN &scn,
mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
if (OB_FAIL(modify_tablet_binding_for_unbind(arg, scn, ctx))) {
LOG_WARN("failed to modify tablet binding", K(ret));
} else {
LOG_INFO("modify_tablet_binding_for_unbind redo", KR(ret), K(scn), K(arg));
}
return ret;
}
int ObTabletUnbindMdsHelper::on_replay(const char* buf, const int64_t len, const share::SCN &scn, mds::BufferCtx &ctx) int ObTabletUnbindMdsHelper::on_replay(const char* buf, const int64_t len, const share::SCN &scn, mds::BufferCtx &ctx)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -308,8 +326,8 @@ int ObTabletUnbindMdsHelper::on_replay(const char* buf, const int64_t len, const
LOG_WARN("failed to deserialize arg", K(ret)); LOG_WARN("failed to deserialize arg", K(ret));
} else if (arg.is_old_mds_) { } else if (arg.is_old_mds_) {
LOG_INFO("skip unbind mds tablet for old mds", K(arg), K(scn)); LOG_INFO("skip unbind mds tablet for old mds", K(arg), K(scn));
} else if (OB_FAIL(modify_tablet_binding_for_unbind(arg, scn, ctx))) { } else if (OB_FAIL(replay_process(arg, scn, ctx))) {
LOG_WARN("failed to modify tablet binding", K(ret)); LOG_WARN("failed to replay_process", K(ret));
} }
return ret; return ret;
} }
@ -323,7 +341,7 @@ int ObTabletUnbindMdsHelper::unbind_hidden_tablets_from_orig_tablets(
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < arg.orig_tablet_ids_.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < arg.orig_tablet_ids_.count(); i++) {
const ObTabletID &orig_tablet = arg.orig_tablet_ids_.at(i); const ObTabletID &orig_tablet = arg.orig_tablet_ids_.at(i);
if (OB_FAIL(ObTabletBindingHelper::modify_tablet_binding_new_mds(ls, orig_tablet, replay_scn, ctx, [&arg](ObTabletBindingMdsUserData &data) -> int { if (OB_FAIL(ObTabletBindingHelper::modify_tablet_binding_new_mds(ls, orig_tablet, replay_scn, ctx, arg.is_old_mds_, [&arg](ObTabletBindingMdsUserData &data) -> int {
data.hidden_tablet_id_.reset(); data.hidden_tablet_id_.reset();
if (arg.is_redefined()) { if (arg.is_redefined()) {
data.redefined_ = true; data.redefined_ = true;
@ -346,7 +364,7 @@ int ObTabletUnbindMdsHelper::set_redefined_versions_for_hidden_tablets(
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < arg.hidden_tablet_ids_.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < arg.hidden_tablet_ids_.count(); i++) {
const ObTabletID &hidden_tablet = arg.hidden_tablet_ids_.at(i); const ObTabletID &hidden_tablet = arg.hidden_tablet_ids_.at(i);
if (OB_FAIL(ObTabletBindingHelper::modify_tablet_binding_new_mds(ls, hidden_tablet, replay_scn, ctx, [&arg](ObTabletBindingMdsUserData &data) -> int { if (OB_FAIL(ObTabletBindingHelper::modify_tablet_binding_new_mds(ls, hidden_tablet, replay_scn, ctx, arg.is_old_mds_, [&arg](ObTabletBindingMdsUserData &data) -> int {
data.redefined_ = false; data.redefined_ = false;
data.snapshot_version_ = OB_INVALID_VERSION; // will be fill back on commit data.snapshot_version_ = OB_INVALID_VERSION; // will be fill back on commit
data.schema_version_ = arg.schema_version_; data.schema_version_ = arg.schema_version_;

View File

@ -84,14 +84,14 @@ public:
// create tablet by new mds // create tablet by new mds
static int modify_tablet_binding_for_new_mds_create(const obrpc::ObBatchCreateTabletArg &arg, const share::SCN &replay_scn, mds::BufferCtx &ctx); static int modify_tablet_binding_for_new_mds_create(const obrpc::ObBatchCreateTabletArg &arg, const share::SCN &replay_scn, mds::BufferCtx &ctx);
static int bind_hidden_tablet_to_orig_tablet(ObLS &ls, const obrpc::ObCreateTabletInfo &info, const share::SCN &replay_scn, mds::BufferCtx &ctx); static int bind_hidden_tablet_to_orig_tablet(ObLS &ls, const obrpc::ObCreateTabletInfo &info, const share::SCN &replay_scn, mds::BufferCtx &ctx, const bool for_old_mds);
static int bind_lob_tablet_to_data_tablet(ObLS &ls, const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObCreateTabletInfo &info, const share::SCN &replay_scn, mds::BufferCtx &ctx); static int bind_lob_tablet_to_data_tablet(ObLS &ls, const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObCreateTabletInfo &info, const share::SCN &replay_scn, mds::BufferCtx &ctx);
// TODO (lihongqin.lhq) delete get_tablet_for_new_mds // TODO (lihongqin.lhq) delete get_tablet_for_new_mds
static int get_tablet_for_new_mds(const ObLS &ls, const ObTabletID &tablet_id, const share::SCN &replay_scn, ObTabletHandle &handle); static int get_tablet_for_new_mds(const ObLS &ls, const ObTabletID &tablet_id, const share::SCN &replay_scn, ObTabletHandle &handle);
// common // common
template<typename F> template<typename F>
static int modify_tablet_binding_new_mds(ObLS &ls, const ObTabletID &tablet_id, const share::SCN &replay_scn, mds::BufferCtx &ctx, F op); static int modify_tablet_binding_new_mds(ObLS &ls, const ObTabletID &tablet_id, const share::SCN &replay_scn, mds::BufferCtx &ctx, const bool for_old_mds, F op);
static bool has_lob_tablets(const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObCreateTabletInfo &info); static bool has_lob_tablets(const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObCreateTabletInfo &info);
static int get_ls(const share::ObLSID &ls_id, ObLSHandle &ls_handle); static int get_ls(const share::ObLSID &ls_id, ObLSHandle &ls_handle);
private: private:
@ -107,6 +107,7 @@ public:
static int on_register(const char* buf, const int64_t len, mds::BufferCtx &ctx); static int on_register(const char* buf, const int64_t len, mds::BufferCtx &ctx);
static int register_process(ObBatchUnbindTabletArg &arg, mds::BufferCtx &ctx); static int register_process(ObBatchUnbindTabletArg &arg, mds::BufferCtx &ctx);
static int on_commit_for_old_mds(const char* buf, const int64_t len, const transaction::ObMulSourceDataNotifyArg &notify_arg); static int on_commit_for_old_mds(const char* buf, const int64_t len, const transaction::ObMulSourceDataNotifyArg &notify_arg);
static int replay_process(ObBatchUnbindTabletArg &arg, const share::SCN &scn, mds::BufferCtx &ctx);
static int on_replay(const char* buf, const int64_t len, const share::SCN &scn, mds::BufferCtx &ctx); static int on_replay(const char* buf, const int64_t len, const share::SCN &scn, mds::BufferCtx &ctx);
private: private:
static int unbind_hidden_tablets_from_orig_tablets(ObLS &ls, const ObBatchUnbindTabletArg &arg, const share::SCN &replay_scn, mds::BufferCtx &ctx); static int unbind_hidden_tablets_from_orig_tablets(ObLS &ls, const ObBatchUnbindTabletArg &arg, const share::SCN &replay_scn, mds::BufferCtx &ctx);

View File

@ -27,7 +27,8 @@ ObTabletBindingReplayExecutor::ObTabletBindingReplayExecutor()
int ObTabletBindingReplayExecutor::init( int ObTabletBindingReplayExecutor::init(
mds::BufferCtx &user_ctx, mds::BufferCtx &user_ctx,
ObTabletBindingMdsUserData &user_data, ObTabletBindingMdsUserData &user_data,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_UNLIKELY(is_inited_)) { if (OB_UNLIKELY(is_inited_)) {
@ -40,6 +41,7 @@ int ObTabletBindingReplayExecutor::init(
user_ctx_ = &user_ctx; user_ctx_ = &user_ctx;
user_data_ = &user_data; user_data_ = &user_data;
scn_ = scn; scn_ = scn;
for_old_mds_ = for_old_mds;
is_inited_ = true; is_inited_ = true;
} }
return ret; return ret;
@ -51,7 +53,7 @@ int ObTabletBindingReplayExecutor::do_replay_(ObTabletHandle &tablet_handle)
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
mds::MdsCtx &user_ctx = static_cast<mds::MdsCtx&>(*user_ctx_); mds::MdsCtx &user_ctx = static_cast<mds::MdsCtx&>(*user_ctx_);
if (OB_FAIL(replay_to_mds_table_(tablet_handle, *user_data_, user_ctx, scn_))) { if (OB_FAIL(replay_to_mds_table_(tablet_handle, *user_data_, user_ctx, scn_, for_old_mds_))) {
LOG_WARN("failed to replay to tablet", K(ret)); LOG_WARN("failed to replay to tablet", K(ret));
} }

View File

@ -31,7 +31,8 @@ public:
int init( int init(
mds::BufferCtx &user_ctx, mds::BufferCtx &user_ctx,
ObTabletBindingMdsUserData &user_data, ObTabletBindingMdsUserData &user_data,
const share::SCN &scn); const share::SCN &scn,
const bool for_old_mds);
protected: protected:
bool is_replay_update_tablet_status_() const override bool is_replay_update_tablet_status_() const override
@ -50,6 +51,7 @@ private:
mds::BufferCtx *user_ctx_; mds::BufferCtx *user_ctx_;
ObTabletBindingMdsUserData *user_data_; ObTabletBindingMdsUserData *user_data_;
share::SCN scn_; share::SCN scn_;
bool for_old_mds_;
}; };

View File

@ -153,17 +153,21 @@ int ObTabletCreateDeleteHelper::process_for_old_mds(
mds::MdsCtx mds_ctx; mds::MdsCtx mds_ctx;
mds_ctx.set_binding_type_id(mds::TupleTypeIdx<mds::BufferCtxTupleHelper, mds::MdsCtx>::value); mds_ctx.set_binding_type_id(mds::TupleTypeIdx<mds::BufferCtxTupleHelper, mds::MdsCtx>::value);
mds_ctx.set_writer(mds::MdsWriter(notify_arg.tx_id_)); mds_ctx.set_writer(mds::MdsWriter(notify_arg.tx_id_));
if (notify_arg.for_replay_) {
if (OB_FAIL(Helper::replay_process(arg, notify_arg.scn_, mds_ctx))) {
ret = OB_EAGAIN;
}
} else {
do { do {
if (OB_FAIL(Helper::register_process(arg, mds_ctx))) { if (OB_FAIL(Helper::register_process(arg, mds_ctx))) {
TRANS_LOG(ERROR, "fail to register_process, retry", K(ret), K(arg)); TRANS_LOG(ERROR, "fail to register_process, retry", K(ret), K(arg));
usleep(100 * 1000); usleep(100 * 1000);
} }
} while (OB_FAIL(ret) && !notify_arg.for_replay_); } while (OB_FAIL(ret));
}
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (notify_arg.for_replay_) {
ret = OB_EAGAIN;
}
} else { } else {
mds_ctx.single_log_commit(notify_arg.trans_version_, notify_arg.scn_); mds_ctx.single_log_commit(notify_arg.trans_version_, notify_arg.scn_);
TRANS_LOG(INFO, "replay create commit for old_mds", KR(ret), K(arg)); TRANS_LOG(INFO, "replay create commit for old_mds", KR(ret), K(arg));

View File

@ -46,7 +46,8 @@ public:
int init( int init(
mds::BufferCtx &user_ctx, mds::BufferCtx &user_ctx,
const share::SCN &scn); const share::SCN &scn,
const bool for_old_mds);
protected: protected:
bool is_replay_update_tablet_status_() const override bool is_replay_update_tablet_status_() const override
@ -64,6 +65,7 @@ protected:
private: private:
mds::BufferCtx *user_ctx_; mds::BufferCtx *user_ctx_;
share::SCN scn_; share::SCN scn_;
bool for_old_mds_;
}; };
@ -73,7 +75,8 @@ ObTabletCreateReplayExecutor::ObTabletCreateReplayExecutor()
int ObTabletCreateReplayExecutor::init( int ObTabletCreateReplayExecutor::init(
mds::BufferCtx &user_ctx, mds::BufferCtx &user_ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_UNLIKELY(is_inited_)) { if (OB_UNLIKELY(is_inited_)) {
@ -86,6 +89,7 @@ int ObTabletCreateReplayExecutor::init(
user_ctx_ = &user_ctx; user_ctx_ = &user_ctx;
scn_ = scn; scn_ = scn;
is_inited_ = true; is_inited_ = true;
for_old_mds_ = for_old_mds;
} }
return ret; return ret;
} }
@ -96,7 +100,7 @@ int ObTabletCreateReplayExecutor::do_replay_(ObTabletHandle &tablet_handle)
mds::MdsCtx &user_ctx = static_cast<mds::MdsCtx&>(*user_ctx_); mds::MdsCtx &user_ctx = static_cast<mds::MdsCtx&>(*user_ctx_);
ObTabletCreateDeleteMdsUserData user_data(ObTabletStatus::NORMAL, ObTabletMdsUserDataType::CREATE_TABLET); ObTabletCreateDeleteMdsUserData user_data(ObTabletStatus::NORMAL, ObTabletMdsUserDataType::CREATE_TABLET);
if (OB_FAIL(replay_to_mds_table_(tablet_handle, user_data, user_ctx, scn_))) { if (OB_FAIL(replay_to_mds_table_(tablet_handle, user_data, user_ctx, scn_, for_old_mds_))) {
LOG_WARN("failed to replay to tablet", K(ret)); LOG_WARN("failed to replay to tablet", K(ret));
} }
@ -176,33 +180,19 @@ int ObTabletCreateMdsHelper::on_register(
return ret; return ret;
} }
int ObTabletCreateMdsHelper::on_replay( int ObTabletCreateMdsHelper::replay_process(
const char* buf, const ObBatchCreateTabletArg &arg,
const int64_t len,
const share::SCN &scn, const share::SCN &scn,
mds::BufferCtx &ctx) mds::BufferCtx &ctx)
{ {
MDS_TG(1_s); MDS_TG(1_s);
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObBatchCreateTabletArg arg;
int64_t pos = 0;
common::ObSArray<ObTabletID> tablet_id_array; common::ObSArray<ObTabletID> tablet_id_array;
const ObLSID &ls_id = arg.id_; const ObLSID &ls_id = arg.id_;
ObLSHandle ls_handle; ObLSHandle ls_handle;
ObLS *ls = nullptr; ObLS *ls = nullptr;
share::SCN tablet_change_checkpoint_scn; share::SCN tablet_change_checkpoint_scn;
if (CLICK_FAIL(tablet_id_array.reserve(arg.get_tablet_count()))) {
if (OB_ISNULL(buf) || OB_UNLIKELY(len <= 0) || OB_UNLIKELY(!scn.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", K(ret), KP(buf), K(len), K(scn));
} else if (CLICK_FAIL(arg.deserialize(buf, len, pos))) {
LOG_WARN("failed to deserialize", K(ret));
} else if (OB_UNLIKELY(!arg.is_valid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("arg is invalid", K(ret), K(PRINT_CREATE_ARG(arg)));
} else if (arg.is_old_mds_) {
LOG_INFO("skip replay create tablet for old mds", K(arg), K(scn));
} else if (CLICK_FAIL(tablet_id_array.reserve(arg.get_tablet_count()))) {
LOG_WARN("failed to reserve memory", K(ret), "capacity", arg.get_tablet_count()); LOG_WARN("failed to reserve memory", K(ret), "capacity", arg.get_tablet_count());
} else if (CLICK_FAIL(get_ls(ls_id, ls_handle))) { } else if (CLICK_FAIL(get_ls(ls_id, ls_handle))) {
LOG_WARN("failed to get ls", K(ret), K(ls_id)); LOG_WARN("failed to get ls", K(ret), K(ls_id));
@ -231,6 +221,38 @@ int ObTabletCreateMdsHelper::on_replay(
} }
} }
LOG_INFO("create tablet replay", KR(ret), K(arg), K(scn)); LOG_INFO("create tablet replay", KR(ret), K(arg), K(scn));
return ret;
}
int ObTabletCreateMdsHelper::on_replay(
const char* buf,
const int64_t len,
const share::SCN &scn,
mds::BufferCtx &ctx)
{
MDS_TG(1_s);
int ret = OB_SUCCESS;
ObBatchCreateTabletArg arg;
int64_t pos = 0;
common::ObSArray<ObTabletID> tablet_id_array;
const ObLSID &ls_id = arg.id_;
ObLSHandle ls_handle;
ObLS *ls = nullptr;
share::SCN tablet_change_checkpoint_scn;
if (OB_ISNULL(buf) || OB_UNLIKELY(len <= 0) || OB_UNLIKELY(!scn.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", K(ret), KP(buf), K(len), K(scn));
} else if (CLICK_FAIL(arg.deserialize(buf, len, pos))) {
LOG_WARN("failed to deserialize", K(ret));
} else if (OB_UNLIKELY(!arg.is_valid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("arg is invalid", K(ret), K(PRINT_CREATE_ARG(arg)));
} else if (arg.is_old_mds_) {
LOG_INFO("skip replay create tablet for old mds", K(arg), K(scn));
} else if (CLICK_FAIL(replay_process(arg, scn, ctx))) {
LOG_WARN("fail to replay_process", K(ret), K(PRINT_CREATE_ARG(arg)));
}
return ret; return ret;
} }
@ -623,7 +645,7 @@ int ObTabletCreateMdsHelper::build_pure_data_tablet(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
} else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx))) { } else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx, arg.is_old_mds_))) {
LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(data_tablet_id)); LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(data_tablet_id));
} }
@ -697,7 +719,7 @@ int ObTabletCreateMdsHelper::build_mixed_tablets(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
} else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx))) { } else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx, arg.is_old_mds_))) {
LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id));
} }
@ -782,7 +804,7 @@ int ObTabletCreateMdsHelper::build_pure_aux_tablets(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
} else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx))) { } else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx, arg.is_old_mds_))) {
LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id));
} }
} }
@ -870,7 +892,7 @@ int ObTabletCreateMdsHelper::build_hidden_tablets(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
} else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx))) { } else if (CLICK_FAIL(set_tablet_normal_status(ls->get_tablet_svr(), tablet_handle, for_replay, scn, ctx, arg.is_old_mds_))) {
LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("failed to set tablet normal status", K(ret), K(ls_id), K(tablet_id));
} }
@ -938,7 +960,8 @@ int ObTabletCreateMdsHelper::set_tablet_normal_status(
ObTabletHandle &tablet_handle, ObTabletHandle &tablet_handle,
const bool for_replay, const bool for_replay,
const share::SCN &scn, const share::SCN &scn,
mds::BufferCtx &ctx) mds::BufferCtx &ctx,
const bool for_old_mds)
{ {
MDS_TG(5_ms); MDS_TG(5_ms);
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -959,7 +982,7 @@ int ObTabletCreateMdsHelper::set_tablet_normal_status(
ObTabletCreateReplayExecutor replay_executor; ObTabletCreateReplayExecutor replay_executor;
const share::ObLSID &ls_id = tablet->get_tablet_meta().ls_id_; const share::ObLSID &ls_id = tablet->get_tablet_meta().ls_id_;
const common::ObTabletID &tablet_id = tablet->get_tablet_meta().tablet_id_; const common::ObTabletID &tablet_id = tablet->get_tablet_meta().tablet_id_;
if (CLICK_FAIL(replay_executor.init(ctx, scn))) { if (CLICK_FAIL(replay_executor.init(ctx, scn, for_old_mds))) {
LOG_WARN("failed to init replay executor", K(ret)); LOG_WARN("failed to init replay executor", K(ret));
} else if (CLICK_FAIL(replay_executor.execute(scn, ls_id, tablet_id))) { } else if (CLICK_FAIL(replay_executor.execute(scn, ls_id, tablet_id))) {
LOG_WARN("failed to replay mds data", K(ret)); LOG_WARN("failed to replay mds data", K(ret));

View File

@ -72,6 +72,10 @@ public:
static int register_process( static int register_process(
const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObBatchCreateTabletArg &arg,
mds::BufferCtx &ctx); mds::BufferCtx &ctx);
static int replay_process(
const obrpc::ObBatchCreateTabletArg &arg,
const share::SCN &scn,
mds::BufferCtx &ctx);
private: private:
static int check_create_new_tablets(const obrpc::ObBatchCreateTabletArg &arg); static int check_create_new_tablets(const obrpc::ObBatchCreateTabletArg &arg);
static int check_create_arg( static int check_create_arg(
@ -147,7 +151,8 @@ private:
ObTabletHandle &tablet_handle, ObTabletHandle &tablet_handle,
const bool for_replay, const bool for_replay,
const share::SCN &scn, const share::SCN &scn,
mds::BufferCtx &ctx); mds::BufferCtx &ctx,
const bool for_old_mds);
}; };
} // namespace storage } // namespace storage
} // namespace oceanbase } // namespace oceanbase

View File

@ -83,6 +83,25 @@ int ObTabletDeleteMdsHelper::on_register(
return ret; return ret;
} }
int ObTabletDeleteMdsHelper::replay_process(
obrpc::ObBatchRemoveTabletArg &arg,
const share::SCN &scn,
mds::BufferCtx &ctx)
{
MDS_TG(1_s);
int ret = OB_SUCCESS;
if (CLICK_FAIL(replay_delete_tablets(arg, scn, ctx))) {
LOG_WARN("failed to delete tablets", K(ret), K(arg), K(scn));
} else if (CLICK_FAIL(ObTabletCreateDeleteMdsUserData::set_tablet_empty_shell_trigger(arg.id_))) {
LOG_WARN("failed to set_tablet_empty_shell_trigger", K(ret), K(arg));
} else {
LOG_INFO("delete tablet replay", KR(ret), K(arg));
}
return ret;
}
int ObTabletDeleteMdsHelper::on_replay( int ObTabletDeleteMdsHelper::on_replay(
const char* buf, const char* buf,
const int64_t len, const int64_t len,
@ -102,12 +121,8 @@ int ObTabletDeleteMdsHelper::on_replay(
LOG_WARN("failed to deserialize", K(ret)); LOG_WARN("failed to deserialize", K(ret));
} else if (arg.is_old_mds_) { } else if (arg.is_old_mds_) {
LOG_INFO("skip replay delete tablet for old mds", K(arg), K(scn)); LOG_INFO("skip replay delete tablet for old mds", K(arg), K(scn));
} else if (CLICK_FAIL(replay_delete_tablets(arg, scn, ctx))) { } else if (CLICK_FAIL(replay_process(arg, scn, ctx))) {
LOG_WARN("failed to delete tablets", K(ret), K(arg), K(scn)); LOG_WARN("failed to replay_process", K(ret), K(arg));
} else if (CLICK_FAIL(ObTabletCreateDeleteMdsUserData::set_tablet_empty_shell_trigger(arg.id_))) {
LOG_WARN("failed to set_tablet_empty_shell_trigger", K(ret), K(arg));
} else {
LOG_INFO("delete tablet replay", KR(ret), K(arg));
} }
return ret; return ret;
@ -181,7 +196,7 @@ int ObTabletDeleteMdsHelper::replay_delete_tablets(
exist = true; exist = true;
remove_tablet_arg.tablet_id_ = arg.tablet_ids_.at(i); remove_tablet_arg.tablet_id_ = arg.tablet_ids_.at(i);
ObTabletDeleteReplayExecutor replayer; ObTabletDeleteReplayExecutor replayer;
if (CLICK_FAIL(replayer.init(ctx, scn))) { if (CLICK_FAIL(replayer.init(ctx, scn, arg.is_old_mds_))) {
LOG_WARN("failed to init tablet delete replay executor", K(ret), K(remove_tablet_arg)); LOG_WARN("failed to init tablet delete replay executor", K(ret), K(remove_tablet_arg));
} else if (CLICK_FAIL(replayer.execute(scn, remove_tablet_arg.ls_id_, remove_tablet_arg.tablet_id_))) { } else if (CLICK_FAIL(replayer.execute(scn, remove_tablet_arg.ls_id_, remove_tablet_arg.tablet_id_))) {
if (OB_TABLET_NOT_EXIST == ret) { if (OB_TABLET_NOT_EXIST == ret) {

View File

@ -57,6 +57,10 @@ public:
const int64_t len, const int64_t len,
const share::SCN &scn, const share::SCN &scn,
mds::BufferCtx &ctx); mds::BufferCtx &ctx);
static int replay_process(
obrpc::ObBatchRemoveTabletArg &arg,
const share::SCN &scn,
mds::BufferCtx &ctx);
private: private:
static int delete_tablets( static int delete_tablets(
const obrpc::ObBatchRemoveTabletArg &arg, const obrpc::ObBatchRemoveTabletArg &arg,

View File

@ -34,7 +34,8 @@ ObTabletDeleteReplayExecutor::ObTabletDeleteReplayExecutor()
int ObTabletDeleteReplayExecutor::init( int ObTabletDeleteReplayExecutor::init(
mds::BufferCtx &ctx, mds::BufferCtx &ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_UNLIKELY(is_inited_)) { if (OB_UNLIKELY(is_inited_)) {
@ -46,6 +47,7 @@ int ObTabletDeleteReplayExecutor::init(
} else { } else {
ctx_ = &ctx; ctx_ = &ctx;
scn_ = scn; scn_ = scn;
for_old_mds_ = for_old_mds;
is_inited_ = true; is_inited_ = true;
} }
return ret; return ret;
@ -67,7 +69,7 @@ int ObTabletDeleteReplayExecutor::do_replay_(ObTabletHandle &tablet_handle)
} else { } else {
data.tablet_status_ = ObTabletStatus::DELETED; data.tablet_status_ = ObTabletStatus::DELETED;
data.data_type_ = ObTabletMdsUserDataType::REMOVE_TABLET; data.data_type_ = ObTabletMdsUserDataType::REMOVE_TABLET;
if (CLICK_FAIL(replay_to_mds_table_(tablet_handle, data, user_ctx, scn_))) { if (CLICK_FAIL(replay_to_mds_table_(tablet_handle, data, user_ctx, scn_, for_old_mds_))) {
LOG_WARN("failed to replay to tablet", K(ret)); LOG_WARN("failed to replay to tablet", K(ret));
} }
} }

View File

@ -44,7 +44,7 @@ class ObTabletDeleteReplayExecutor final : public logservice::ObTabletReplayExec
public: public:
ObTabletDeleteReplayExecutor(); ObTabletDeleteReplayExecutor();
int init(mds::BufferCtx &ctx, const share::SCN &scn); int init(mds::BufferCtx &ctx, const share::SCN &scn, const bool for_old_mds);
protected: protected:
bool is_replay_update_tablet_status_() const override bool is_replay_update_tablet_status_() const override
@ -63,6 +63,7 @@ private:
const ObRemoveTabletArg *arg_; const ObRemoveTabletArg *arg_;
mds::BufferCtx *ctx_; mds::BufferCtx *ctx_;
share::SCN scn_; share::SCN scn_;
bool for_old_mds_;
}; };

View File

@ -67,7 +67,8 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletCreateDeleteMdsUserData &mds, const ObTabletCreateDeleteMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = 123; int ret = 123;
UNUSEDx(tablet_handle, mds, ctx, scn); UNUSEDx(tablet_handle, mds, ctx, scn);
@ -78,7 +79,8 @@ int ObTabletReplayExecutor::replay_to_mds_table_(
storage::ObTabletHandle &tablet_handle, storage::ObTabletHandle &tablet_handle,
const ObTabletBindingMdsUserData &mds, const ObTabletBindingMdsUserData &mds,
storage::mds::MdsCtx &ctx, storage::mds::MdsCtx &ctx,
const share::SCN &scn) const share::SCN &scn,
const bool for_old_mds)
{ {
int ret = 456; int ret = 456;
UNUSEDx(tablet_handle, mds, ctx, scn); UNUSEDx(tablet_handle, mds, ctx, scn);