refactor mds table merge dag

This commit is contained in:
hiddenbomb
2023-07-20 07:18:18 +00:00
committed by ob-robot
parent 7977b8cc58
commit 494e1e06f6
19 changed files with 249 additions and 239 deletions

View File

@ -1333,27 +1333,26 @@ int ObLS::update_tablet_table_store(
const int64_t read_lock = LSLOCKLOGMETA;
const int64_t write_lock = 0;
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
const share::ObLSID &ls_id = ls_meta_.ls_id_;
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ls is not inited", K(ret));
} else if (OB_UNLIKELY(!tablet_id.is_valid() || !param.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("update tablet table store get invalid argument", K(ret), K(tablet_id), K(param));
} else {
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
if (param.rebuild_seq_ != rebuild_seq) {
ret = OB_EAGAIN;
LOG_WARN("update tablet table store rebuild seq not same, need retry",
K(ret), K(tablet_id), K(rebuild_seq), K(param));
} else if (OB_FAIL(ls_tablet_svr_.update_tablet_table_store(tablet_id, param, handle))) {
LOG_WARN("failed to update tablet table store", K(ret), K(tablet_id), K(param));
}
LOG_WARN("update tablet table store get invalid argument", K(ret), K(ls_id), K(tablet_id), K(param));
} else if (param.rebuild_seq_ != rebuild_seq) {
ret = OB_EAGAIN;
LOG_WARN("update tablet table store rebuild seq not same, need retry",
K(ret), K(ls_id), K(tablet_id), K(rebuild_seq), K(param));
} else if (OB_FAIL(ls_tablet_svr_.update_tablet_table_store(tablet_id, param, handle))) {
LOG_WARN("failed to update tablet table store", K(ret), K(ls_id), K(tablet_id), K(param));
}
return ret;
}
int ObLS::update_tablet_table_store(
const int64_t rebuild_seq,
const int64_t ls_rebuild_seq,
const ObTabletHandle &old_tablet_handle,
const ObIArray<storage::ObITable *> &tables)
{
@ -1368,12 +1367,14 @@ int ObLS::update_tablet_table_store(
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(old_tablet_handle), K(tables));
} else {
const int64_t seq = ls_meta_.get_rebuild_seq();
if (rebuild_seq != seq) {
const share::ObLSID &ls_id = ls_meta_.ls_id_;
const common::ObTabletID &tablet_id = old_tablet_handle.get_obj()->get_tablet_meta().tablet_id_;
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
if (OB_UNLIKELY(ls_rebuild_seq != rebuild_seq)) {
ret = OB_EAGAIN;
LOG_WARN("rebuild seq has changed, retry", K(ret), K(seq), K(rebuild_seq));
LOG_WARN("rebuild seq has changed, retry", K(ret), K(ls_id), K(tablet_id), K(rebuild_seq), K(ls_rebuild_seq));
} else if (OB_FAIL(ls_tablet_svr_.update_tablet_table_store(old_tablet_handle, tables))) {
LOG_WARN("fail to replace small sstables in the tablet", K(ret), K(old_tablet_handle), K(tables));
LOG_WARN("fail to replace small sstables in the tablet", K(ret), K(ls_id), K(tablet_id), K(old_tablet_handle), K(tables));
}
}
return ret;
@ -1387,21 +1388,47 @@ int ObLS::build_ha_tablet_new_table_store(
int64_t read_lock = LSLOCKLOGMETA;
int64_t write_lock = 0;
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
const share::ObLSID &ls_id = ls_meta_.ls_id_;
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ls is not inited", K(ret));
} else if (!tablet_id.is_valid() || !param.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("build ha tablet new table store get invalid argument", K(ret), K(tablet_id), K(param));
} else {
if (param.rebuild_seq_ != rebuild_seq) {
ret = OB_EAGAIN;
LOG_WARN("build ha tablet new table store rebuild seq not same, need retry",
K(ret), K(tablet_id), K(rebuild_seq), K(param));
} else if (OB_FAIL(ls_tablet_svr_.build_ha_tablet_new_table_store(tablet_id, param))) {
LOG_WARN("failed to update tablet table store", K(ret), K(tablet_id), K(param));
}
LOG_WARN("build ha tablet new table store get invalid argument", K(ret), K(ls_id), K(tablet_id), K(param));
} else if (param.rebuild_seq_ != rebuild_seq) {
ret = OB_EAGAIN;
LOG_WARN("build ha tablet new table store rebuild seq not same, need retry",
K(ret), K(ls_id), K(tablet_id), K(rebuild_seq), K(param));
} else if (OB_FAIL(ls_tablet_svr_.build_ha_tablet_new_table_store(tablet_id, param))) {
LOG_WARN("failed to update tablet table store", K(ret), K(ls_id), K(tablet_id), K(param));
}
return ret;
}
int ObLS::build_new_tablet_from_mds_table(
const int64_t ls_rebuild_seq,
const common::ObTabletID &tablet_id,
const share::SCN &flush_scn)
{
int ret = OB_SUCCESS;
const int64_t read_lock = LSLOCKLOGMETA;
const int64_t write_lock = 0;
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
const share::ObLSID &ls_id = ls_meta_.ls_id_;
const int64_t rebuild_seq = ls_meta_.get_rebuild_seq();
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ls is not inited", K(ret));
} else if (OB_UNLIKELY(!tablet_id.is_valid() || !flush_scn.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", K(ret), K(ls_id), K(tablet_id), K(flush_scn));
} else if (OB_UNLIKELY(ls_rebuild_seq != rebuild_seq)) {
ret = OB_EAGAIN;
LOG_WARN("rebuild seq is not the same with current ls, need retry",
K(ret), K(ls_id), K(tablet_id), K(ls_rebuild_seq), K(rebuild_seq), K(flush_scn));
} else if (OB_FAIL(ls_tablet_svr_.build_new_tablet_from_mds_table(tablet_id, flush_scn))) {
LOG_WARN("failed to build new tablet from mds table", K(ret), K(ls_id), K(tablet_id), K(flush_scn));
}
return ret;
}