fixbug: hung up when creating local index

This commit is contained in:
791065426@qq.com
2024-06-27 09:46:42 +00:00
committed by ob-robot
parent 0400ebf152
commit d5707dd327
2 changed files with 48 additions and 0 deletions

View File

@ -101,6 +101,8 @@ int ObDDLTabletScheduler::init(const uint64_t tenant_id,
LOG_WARN("fail to create column checksum map", K(ret), K(ref_data_table_tablets.count()));
} else if (OB_FAIL(tablet_id_to_data_row_cnt_.create(ref_data_table_tablets.count(), ObModIds::OB_SSTABLE_CREATE_INDEX))) {
LOG_WARN("fail to create column checksum map", K(ret), K(ref_data_table_tablets.count()));
} else if (OB_FAIL(tablet_scheduled_times_statistic_.create(ref_data_table_tablets.count(), ObModIds::OB_SSTABLE_CREATE_INDEX))) {
LOG_WARN("fail to create tablet scheduled count statistic map", K(ret), K(ref_data_table_tablets.count()));
} else if (OB_FAIL(ObDDLChecksumOperator::get_tablet_checksum_record_without_execution_id(
tenant_id,
table_id,
@ -298,6 +300,29 @@ int ObDDLTabletScheduler::confirm_batch_tablets_status(const int64_t execution_i
return ret;
}
int ObDDLTabletScheduler::refresh_ls_location_map() {
int ret = OB_SUCCESS;
TCRLockGuard guard(lock_);
common::hash::ObHashMap<share::ObLSID, common::ObAddr>::iterator iter;
for (iter = ls_location_map_.begin(); iter != ls_location_map_.end() && OB_SUCC(ret); ++iter) {
const ObLSID ls_id = iter->first;
common::ObAddr leader_addr;
share::ObLocationService *location_service = nullptr;
int64_t rpc_timeout = ObDDLUtil::get_default_ddl_rpc_timeout();
const int64_t retry_interval_us = 200 * 1000; // 200ms
if (OB_ISNULL(location_service = GCTX.location_service_)) {
ret = OB_ERR_SYS;
LOG_WARN("location_cache is null", K(ret), KP(location_service));
} else if (OB_FAIL(location_service->get_leader_with_retry_until_timeout(GCONF.cluster_id,
tenant_id_, ls_id, leader_addr, rpc_timeout, retry_interval_us))) {
LOG_WARN("fail to get ls locaiton leader", K(ret), K(tenant_id_), K(ls_id));
} else if (OB_FAIL(ls_location_map_.set_refactored(ls_id, leader_addr, true /* overwrite */))) {
LOG_WARN("ls location map set fail", K(ret), K(ls_id), K(leader_addr));
}
}
return ret;
}
int ObDDLTabletScheduler::get_next_parallelism(int64_t &parallelism)
{
int ret = OB_SUCCESS;
@ -511,6 +536,26 @@ int ObDDLTabletScheduler::calculate_candidate_tablets(const uint64_t left_space_
pre_data_size = pre_data_size + tablet_data_size;
pre_data_row_cnt = pre_data_row_cnt + tablet_data_row_cnt;
}
if (OB_SUCC(ret)) {
int64_t has_scheduled_times = 0;
if (OB_FAIL(tablet_scheduled_times_statistic_.get_refactored(in_tablets.at(i).id(), has_scheduled_times))) {
if (OB_UNLIKELY(OB_HASH_NOT_EXIST == ret)) {
has_scheduled_times = 0;
ret = OB_SUCCESS;
}
} else {
LOG_WARN("tablet scheduled times exceed 1, need to refresh ls location map", K(ret), K(in_tablets.at(i).id()), K(has_scheduled_times));
if (OB_FAIL(refresh_ls_location_map())) {
LOG_WARN("fail to refresh ls location map", K(ret));
}
}
if (OB_SUCC(ret)) {
has_scheduled_times = has_scheduled_times + 1;
if (OB_FAIL(tablet_scheduled_times_statistic_.set_refactored(in_tablets.at(i).id(), has_scheduled_times, true /* overwrite */))) {
LOG_WARN("tablet scheduled times statistic map set fail", K(ret), K(in_tablets.at(i).id()), K(has_scheduled_times));
}
}
}
} else {
break;
}
@ -708,6 +753,7 @@ void ObDDLTabletScheduler::destroy()
running_ls_to_execution_id_.destroy();
tablet_id_to_data_size_.destroy();
tablet_id_to_data_row_cnt_.destroy();
tablet_scheduled_times_statistic_.destroy();
}
int ObTabletIdUpdater::operator() (common::hash::HashMapPair<share::ObLSID, ObArray<ObTabletID>> &entry) {

View File

@ -49,6 +49,7 @@ private:
int check_target_ls_tasks_completion_status(const share::ObLSID &ls_id);
bool is_all_tasks_finished();
bool is_running_tasks_before_finished();
int refresh_ls_location_map();
void destroy();
private:
bool is_inited_;
@ -70,6 +71,7 @@ private:
common::hash::ObHashMap<share::ObLSID, int64_t> running_ls_to_execution_id_;
common::hash::ObHashMap<int64_t, int64_t> tablet_id_to_data_size_;
common::hash::ObHashMap<int64_t, int64_t> tablet_id_to_data_row_cnt_;
common::hash::ObHashMap<int64_t, int64_t> tablet_scheduled_times_statistic_;
};
class ObTabletIdUpdater final