check inner_table before schedule for non-primary tenant
This commit is contained in:
@ -155,6 +155,8 @@ int ObMediumCompactionScheduleFunc::choose_major_snapshot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ObMediumCompactionScheduleFunc::get_status_from_inner_table(
|
int ObMediumCompactionScheduleFunc::get_status_from_inner_table(
|
||||||
|
const ObLSID &ls_id,
|
||||||
|
const ObTabletID &tablet_id,
|
||||||
ObTabletCompactionScnInfo &ret_info)
|
ObTabletCompactionScnInfo &ret_info)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -162,8 +164,8 @@ int ObMediumCompactionScheduleFunc::get_status_from_inner_table(
|
|||||||
|
|
||||||
ObTabletCompactionScnInfo snapshot_info(
|
ObTabletCompactionScnInfo snapshot_info(
|
||||||
MTL_ID(),
|
MTL_ID(),
|
||||||
ls_.get_ls_id(),
|
ls_id,
|
||||||
tablet_.get_tablet_meta().tablet_id_,
|
tablet_id,
|
||||||
ObTabletReplica::SCN_STATUS_IDLE);
|
ObTabletReplica::SCN_STATUS_IDLE);
|
||||||
if (OB_FAIL(ObTabletMetaTableCompactionOperator::get_status(snapshot_info, ret_info))) {
|
if (OB_FAIL(ObTabletMetaTableCompactionOperator::get_status(snapshot_info, ret_info))) {
|
||||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||||
@ -251,7 +253,7 @@ int ObMediumCompactionScheduleFunc::schedule_next_medium_primary_cluster(
|
|||||||
} else if (ObMediumCompactionInfo::MAJOR_COMPACTION == medium_list.get_last_compaction_type()) {
|
} else if (ObMediumCompactionInfo::MAJOR_COMPACTION == medium_list.get_last_compaction_type()) {
|
||||||
// for normal medium, checksum error happened, wait_check_medium_scn_ will never = 0
|
// for normal medium, checksum error happened, wait_check_medium_scn_ will never = 0
|
||||||
// for major, need select inner_table to check RS status
|
// for major, need select inner_table to check RS status
|
||||||
if (OB_FAIL(get_status_from_inner_table(ret_info))) {
|
if (OB_FAIL(get_status_from_inner_table(ls_.get_ls_id(), tablet_.get_tablet_meta().tablet_id_, ret_info))) {
|
||||||
LOG_WARN("failed to get status from inner tablet", K(ret), KPC(this));
|
LOG_WARN("failed to get status from inner tablet", K(ret), KPC(this));
|
||||||
} else if (ret_info.could_schedule_next_round(last_major->get_snapshot_version())) {
|
} else if (ret_info.could_schedule_next_round(last_major->get_snapshot_version())) {
|
||||||
LOG_INFO("success to check RS major checksum validation finished", K(ret), KPC(this), K(ret_info));
|
LOG_INFO("success to check RS major checksum validation finished", K(ret), KPC(this), K(ret_info));
|
||||||
@ -802,12 +804,13 @@ int ObMediumCompactionScheduleFunc::check_medium_finish()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT visit inner table in this func
|
// scheduler_called = false : called in compaction, DO NOT visit inner table in this func
|
||||||
|
// scheduler_called = true : in scheduler loop, could visit inner table
|
||||||
int ObMediumCompactionScheduleFunc::schedule_tablet_medium_merge(
|
int ObMediumCompactionScheduleFunc::schedule_tablet_medium_merge(
|
||||||
ObLS &ls,
|
ObLS &ls,
|
||||||
ObTablet &tablet,
|
ObTablet &tablet,
|
||||||
const int64_t input_major_snapshot,
|
const int64_t input_major_snapshot,
|
||||||
const bool schedule_with_memtable)
|
const bool scheduler_called)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
#ifdef ERRSIM
|
#ifdef ERRSIM
|
||||||
@ -817,26 +820,50 @@ int ObMediumCompactionScheduleFunc::schedule_tablet_medium_merge(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (MTL(ObTenantTabletScheduler *)->could_major_merge_start()) {
|
if (MTL(ObTenantTabletScheduler *)->could_major_merge_start()) {
|
||||||
const ObMediumCompactionInfoList &medium_list = tablet.get_medium_compaction_info_list();
|
const ObMediumCompactionInfoList &medium_list = tablet.get_medium_compaction_info_list();
|
||||||
const ObTabletID &tablet_id = tablet.get_tablet_meta().tablet_id_;
|
const ObTabletID &tablet_id = tablet.get_tablet_meta().tablet_id_;
|
||||||
const ObLSID &ls_id = ls.get_ls_id();
|
const ObLSID &ls_id = ls.get_ls_id();
|
||||||
int64_t major_frozen_snapshot = 0 == input_major_snapshot ? MTL(ObTenantTabletScheduler *)->get_frozen_version() : input_major_snapshot;
|
ObITable *last_major = tablet.get_table_store().get_major_sstables().get_boundary_table(true/*last*/);
|
||||||
ObMediumCompactionInfo::ObCompactionType compaction_type = ObMediumCompactionInfo::COMPACTION_TYPE_MAX;
|
|
||||||
int64_t schedule_scn = 0;
|
|
||||||
bool need_merge = false;
|
|
||||||
|
|
||||||
(void)tablet.get_medium_compaction_info_list().get_schedule_scn(major_frozen_snapshot, schedule_scn, compaction_type);
|
bool schedule_flag = false;
|
||||||
|
if (OB_ISNULL(last_major)) {
|
||||||
|
// do nothing
|
||||||
|
} else if (ObMediumCompactionInfo::MAJOR_COMPACTION == medium_list.get_last_compaction_type()
|
||||||
|
&& !MTL_IS_PRIMARY_TENANT()) { // for STANDBY/RESTORE TENANT
|
||||||
|
ObTabletCompactionScnInfo ret_info;
|
||||||
|
// for standby/restore tenant, need select inner_table to check RS status before schedule new round
|
||||||
|
if (!scheduler_called) { // should not visit inner table, wait for scheduler loop
|
||||||
|
} else if (OB_FAIL(get_status_from_inner_table(ls_id, tablet_id, ret_info))) {
|
||||||
|
LOG_WARN("failed to get status from inner tablet", K(ret), K(ls_id), K(tablet_id));
|
||||||
|
} else if (ret_info.could_schedule_next_round(last_major->get_snapshot_version())) {
|
||||||
|
LOG_INFO("success to check RS major checksum validation finished", K(ret), K(ls_id), K(tablet_id));
|
||||||
|
} else {
|
||||||
|
schedule_flag = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
schedule_flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_DEBUG("schedule_tablet_medium_merge", K(schedule_scn), K(major_frozen_snapshot), K(schedule_with_memtable), K(ls_id), K(tablet_id));
|
if (OB_SUCC(ret) && schedule_flag) {
|
||||||
if (0 == schedule_scn
|
int64_t major_frozen_snapshot = 0 == input_major_snapshot ? MTL(ObTenantTabletScheduler *)->get_frozen_version() : input_major_snapshot;
|
||||||
&& 0 == tablet.get_medium_compaction_info_list().size() // serialized medium list is empty
|
ObMediumCompactionInfo::ObCompactionType compaction_type = ObMediumCompactionInfo::COMPACTION_TYPE_MAX;
|
||||||
&& schedule_with_memtable
|
int64_t schedule_scn = 0;
|
||||||
&& OB_FAIL(get_schedule_medium_from_memtable(tablet, major_frozen_snapshot, schedule_scn, compaction_type))) {
|
bool need_merge = false;
|
||||||
LOG_WARN("failed to get schedule medium scn from memtables", K(ret));
|
|
||||||
} else if (schedule_scn > 0) {
|
(void)tablet.get_medium_compaction_info_list().get_schedule_scn(major_frozen_snapshot, schedule_scn, compaction_type);
|
||||||
if (OB_FAIL(check_need_merge_and_schedule(ls, tablet, schedule_scn, compaction_type))) {
|
|
||||||
LOG_WARN("failed to check medium merge", K(ret), K(ls_id), K(tablet_id), K(schedule_scn));
|
LOG_DEBUG("schedule_tablet_medium_merge", K(schedule_scn), K(major_frozen_snapshot), K(scheduler_called), K(ls_id), K(tablet_id));
|
||||||
|
if (0 == schedule_scn
|
||||||
|
&& 0 == tablet.get_medium_compaction_info_list().size() // serialized medium list is empty
|
||||||
|
&& scheduler_called
|
||||||
|
&& OB_FAIL(get_schedule_medium_from_memtable(tablet, major_frozen_snapshot, schedule_scn, compaction_type))) {
|
||||||
|
LOG_WARN("failed to get schedule medium scn from memtables", K(ret));
|
||||||
|
} else if (schedule_scn > 0) {
|
||||||
|
if (OB_FAIL(check_need_merge_and_schedule(ls, tablet, schedule_scn, compaction_type))) {
|
||||||
|
LOG_WARN("failed to check medium merge", K(ret), K(ls_id), K(tablet_id), K(schedule_scn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public:
|
|||||||
ObLS &ls,
|
ObLS &ls,
|
||||||
ObTablet &tablet,
|
ObTablet &tablet,
|
||||||
const int64_t major_frozen_scn = 0,
|
const int64_t major_frozen_scn = 0,
|
||||||
const bool schedule_with_memtable = false);
|
const bool scheduler_called = false);
|
||||||
static int get_latest_storage_schema_from_memtable(
|
static int get_latest_storage_schema_from_memtable(
|
||||||
ObIAllocator &allocator,
|
ObIAllocator &allocator,
|
||||||
const ObIArray<ObITable *> &memtables,
|
const ObIArray<ObITable *> &memtables,
|
||||||
@ -65,7 +65,10 @@ public:
|
|||||||
int64_t to_string(char* buf, const int64_t buf_len) const;
|
int64_t to_string(char* buf, const int64_t buf_len) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int get_status_from_inner_table(share::ObTabletCompactionScnInfo &ret_info);
|
static int get_status_from_inner_table(
|
||||||
|
const ObLSID &ls_id,
|
||||||
|
const ObTabletID &tablet_id,
|
||||||
|
share::ObTabletCompactionScnInfo &ret_info);
|
||||||
int prepare_medium_info(const ObGetMergeTablesResult &result, ObMediumCompactionInfo &medium_info);
|
int prepare_medium_info(const ObGetMergeTablesResult &result, ObMediumCompactionInfo &medium_info);
|
||||||
int init_parallel_range(
|
int init_parallel_range(
|
||||||
const ObGetMergeTablesResult &result,
|
const ObGetMergeTablesResult &result,
|
||||||
|
|||||||
@ -1017,7 +1017,7 @@ int ObTenantTabletScheduler::schedule_ls_medium_merge(
|
|||||||
ls,
|
ls,
|
||||||
*tablet,
|
*tablet,
|
||||||
major_frozen_scn,
|
major_frozen_scn,
|
||||||
true/*schedule_with_memtable*/))) {
|
true/*scheduler_called*/))) {
|
||||||
if (OB_EAGAIN != ret) {
|
if (OB_EAGAIN != ret) {
|
||||||
LOG_WARN("failed to schedule medium", K(tmp_ret), K(ls_id), K(tablet_id));
|
LOG_WARN("failed to schedule medium", K(tmp_ret), K(ls_id), K(tablet_id));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user