[CP] fix io schedule when close resource_plan
This commit is contained in:
@ -24,6 +24,7 @@ using namespace oceanbase::common;
|
||||
ObMClock::ObMClock()
|
||||
: is_inited_(false),
|
||||
is_stopped_(false),
|
||||
is_unlimited_(false),
|
||||
reservation_clock_(),
|
||||
limitation_clock_(),
|
||||
proportion_clock_()
|
||||
@ -52,6 +53,7 @@ int ObMClock::init(const int64_t min_iops, const int64_t max_iops, const int64_t
|
||||
limitation_clock_.last_ns_ = 0;
|
||||
proportion_clock_.iops_ = weight;
|
||||
proportion_clock_.last_ns_ = proportion_ts * 1000L;
|
||||
is_unlimited_ = false;
|
||||
is_stopped_ = false;
|
||||
is_inited_ = true;
|
||||
}
|
||||
@ -84,12 +86,14 @@ void ObMClock::start()
|
||||
void ObMClock::stop()
|
||||
{
|
||||
is_stopped_ = true;
|
||||
is_unlimited_ = true;
|
||||
}
|
||||
|
||||
void ObMClock::destroy()
|
||||
{
|
||||
is_inited_ = false;
|
||||
is_stopped_ = false;
|
||||
is_unlimited_ = false;
|
||||
reservation_clock_.reset();
|
||||
limitation_clock_.reset();
|
||||
proportion_clock_.reset();
|
||||
@ -110,6 +114,11 @@ bool ObMClock::is_stop() const
|
||||
return is_stopped_;
|
||||
}
|
||||
|
||||
bool ObMClock::is_unlimited() const
|
||||
{
|
||||
return is_unlimited_;
|
||||
}
|
||||
|
||||
int ObMClock::calc_phy_clock(const int64_t current_ts, const double iops_scale, const double weight_scale, ObPhyQueue *phy_queue)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -121,6 +130,11 @@ int ObMClock::calc_phy_clock(const int64_t current_ts, const double iops_scale,
|
||||
|| weight_scale <= std::numeric_limits<double>::epsilon())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(current_ts), K(iops_scale), K(weight_scale));
|
||||
} else if (is_unlimited_) {
|
||||
phy_queue->reservation_ts_ = current_ts;
|
||||
phy_queue->group_limitation_ts_ = current_ts;
|
||||
phy_queue->tenant_limitation_ts_ = current_ts;
|
||||
phy_queue->proportion_ts_ = current_ts;
|
||||
} else {
|
||||
reservation_clock_.atom_update(current_ts, iops_scale, phy_queue->reservation_ts_);
|
||||
limitation_clock_.atom_update(current_ts, iops_scale, phy_queue->group_limitation_ts_);
|
||||
@ -489,6 +503,14 @@ int ObTenantIOClock::update_clock_unit_config(const ObTenantIOConfig &io_config)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObTenantIOClock::is_unlimited_config(const ObMClock &clock, const ObTenantIOConfig::GroupConfig &cur_config)
|
||||
{
|
||||
return clock.is_stop() ||
|
||||
cur_config.deleted_ ||
|
||||
cur_config.cleared_ ||
|
||||
(cur_config.min_percent_ == INT64_MAX && cur_config.max_percent_ == INT64_MAX);
|
||||
}
|
||||
|
||||
int ObTenantIOClock::update_io_clock(const int64_t index, const ObTenantIOConfig &io_config, const int64_t all_group_num)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -518,8 +540,9 @@ int ObTenantIOClock::update_io_clock(const int64_t index, const ObTenantIOConfig
|
||||
const ObTenantIOConfig::GroupConfig &cur_config = io_config.group_configs_.at(index);
|
||||
if (!group_clocks_.at(index).is_inited()) {
|
||||
LOG_WARN("clock is not init", K(ret), K(index), K(group_clocks_.at(index)));
|
||||
} else if (group_clocks_.at(index).is_stop() || cur_config.deleted_ || cur_config.cleared_) {
|
||||
// group has been deleted, ignore
|
||||
} else if (is_unlimited_config(group_clocks_.at(index), cur_config)) {
|
||||
group_clocks_.at(index).set_unlimited();
|
||||
LOG_INFO("clock set unlimited", K(group_clocks_.at(index)), K(cur_config));
|
||||
} else if (!cur_config.is_valid()) {
|
||||
LOG_WARN("config is not valid", K(ret), K(index), K(cur_config), K(group_clocks_.at(index)));
|
||||
// stop
|
||||
@ -531,6 +554,9 @@ int ObTenantIOClock::update_io_clock(const int64_t index, const ObTenantIOConfig
|
||||
LOG_WARN("update group io clock failed", K(ret), K(index), K(unit_config), K(cur_config));
|
||||
} else {
|
||||
group_clocks_.at(index).start();
|
||||
if (!is_unlimited_config(group_clocks_.at(index), cur_config)) {
|
||||
group_clocks_.at(index).set_limited();
|
||||
}
|
||||
LOG_INFO("update group clock success", K(index), K(unit_config), K(cur_config));
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -33,18 +33,22 @@ public:
|
||||
void start();
|
||||
void stop();
|
||||
void destroy();
|
||||
void set_unlimited() { is_unlimited_ = true; }
|
||||
void set_limited() { is_unlimited_ = false; }
|
||||
bool is_inited() const;
|
||||
bool is_valid() const;
|
||||
bool is_stop() const;
|
||||
bool is_unlimited() const;
|
||||
int calc_phy_clock(const int64_t current_ts, const double iops_scale, const double weight_scale, ObPhyQueue *phy_queue);
|
||||
int dial_back_reservation_clock(const double iops_scale);
|
||||
int time_out_dial_back(const double iops_scale, const double weight_scale);
|
||||
int dial_back_proportion_clock(const int64_t delta_us);
|
||||
int64_t get_proportion_ts() const;
|
||||
TO_STRING_KV(K(is_inited_), K(is_stopped_), K_(reservation_clock), K_(limitation_clock), K_(proportion_clock));
|
||||
TO_STRING_KV(K(is_inited_), K(is_stopped_), K_(reservation_clock), K_(is_unlimited), K_(limitation_clock), K_(proportion_clock));
|
||||
private:
|
||||
bool is_inited_;
|
||||
bool is_stopped_;
|
||||
bool is_unlimited_; // use this flag to send io_req in useless_queue out ASAP
|
||||
ObAtomIOClock reservation_clock_;
|
||||
ObAtomIOClock limitation_clock_;
|
||||
ObAtomIOClock proportion_clock_;
|
||||
@ -68,6 +72,7 @@ public:
|
||||
int update_io_clock(const int64_t index, const ObTenantIOConfig &io_config, const int64_t all_group_num);
|
||||
int update_clock_unit_config(const ObTenantIOConfig &io_config);
|
||||
int64_t get_min_proportion_ts();
|
||||
bool is_unlimited_config(const ObMClock &clock, const ObTenantIOConfig::GroupConfig &cur_config);
|
||||
void stop_clock(const uint64_t index);
|
||||
TO_STRING_KV(K(is_inited_), "group_clocks", group_clocks_, "other_clock", other_group_clock_,
|
||||
K_(unit_clock), K(io_config_), K(io_usage_));
|
||||
|
||||
@ -702,10 +702,6 @@ int ObIOCalibration::read_from_table()
|
||||
if (OB_FAIL(update_io_ability(tmp_ability))) {
|
||||
LOG_WARN("update io ability failed", K(ret), K(tmp_ability));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(reset_io_ability())) {
|
||||
LOG_WARN("reset io ability failed", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1770,7 +1770,15 @@ int64_t ObTenantIOConfig::to_string(char* buf, const int64_t buf_len) const
|
||||
bool need_comma = false;
|
||||
for (int64_t i = 0; i < group_configs_.count(); ++i) {
|
||||
if (group_configs_.at(i).deleted_ || group_configs_.at(i).cleared_) {
|
||||
continue;
|
||||
if (need_comma) {
|
||||
J_COMMA();
|
||||
}
|
||||
BUF_PRINTF("group_id = ");
|
||||
char group_id[8];
|
||||
snprintf(group_id, sizeof(group_id), "%ld", group_ids_.at(i));
|
||||
J_KV(group_id, group_configs_.at(i).deleted_);
|
||||
J_KV(" cleared", group_configs_.at(i).cleared_);
|
||||
need_comma = true;
|
||||
} else if (!self_valid || group_configs_.at(i).is_valid()) {
|
||||
if (need_comma) {
|
||||
J_COMMA();
|
||||
@ -2087,6 +2095,16 @@ int ObMClockQueue::pop_with_ready_queue(const int64_t current_ts, ObIORequest *&
|
||||
ret = OB_EAGAIN;
|
||||
if (!r_heap_.empty() && !r_heap_.top()->req_list_.is_empty()) {
|
||||
ObPhyQueue *next_tmp_phy_queue = r_heap_.top();
|
||||
if (OB_UNLIKELY(next_tmp_phy_queue->reservation_ts_ == INT64_MAX &&
|
||||
(next_tmp_phy_queue->group_limitation_ts_ == INT64_MAX || next_tmp_phy_queue->tenant_limitation_ts_== INT64_MAX) &&
|
||||
next_tmp_phy_queue->proportion_ts_== INT64_MAX)) {
|
||||
// 对应min = max = 0的极端场景
|
||||
const int64_t current_ts = ObTimeUtility::fast_current_time();
|
||||
next_tmp_phy_queue->reservation_ts_ = current_ts;
|
||||
next_tmp_phy_queue->group_limitation_ts_ = current_ts;
|
||||
next_tmp_phy_queue->tenant_limitation_ts_ = current_ts;
|
||||
next_tmp_phy_queue->proportion_ts_ = current_ts;
|
||||
}
|
||||
if (0 == deadline_ts) {
|
||||
deadline_ts = next_tmp_phy_queue->reservation_ts_;
|
||||
} else {
|
||||
|
||||
@ -563,6 +563,28 @@ int ObIOManager::refresh_tenant_io_config(const uint64_t tenant_id, const ObTena
|
||||
return ret;
|
||||
}
|
||||
|
||||
// for unittest
|
||||
int ObIOManager::modify_group_io_config(const uint64_t tenant_id,
|
||||
const uint64_t index,
|
||||
const int64_t min_percent,
|
||||
const int64_t max_percent,
|
||||
const int64_t weight_percent)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRefHolder<ObTenantIOManager> tenant_holder;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret), K(is_inited_));
|
||||
} else if (OB_FAIL(get_tenant_io_manager(tenant_id, tenant_holder))) {
|
||||
LOG_WARN("get tenant io manager failed", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(tenant_holder.get_ptr()->modify_group_io_config(index, min_percent, max_percent, weight_percent, false, false))) {
|
||||
LOG_WARN("update tenant io config failed", K(ret), K(tenant_id), K(min_percent), K(max_percent), K(weight_percent));
|
||||
} else if (OB_FAIL(tenant_holder.get_ptr()->refresh_group_io_config())) {
|
||||
LOG_WARN("fail to refresh group config", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObIOManager::get_tenant_io_manager(const uint64_t tenant_id, ObRefHolder<ObTenantIOManager> &tenant_holder)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1368,7 +1390,7 @@ int ObTenantIOManager::reset_all_group_config()
|
||||
for (int64_t i = 0; i < io_config_.group_num_; ++i) {
|
||||
if(io_config_.group_configs_.at(i).deleted_) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(modify_group_io_config(i, 0, 0, 0, false, true/*cleared*/))) {
|
||||
} else if (OB_FAIL(modify_group_io_config(i, 0, 100, 0, false, true/*cleared*/))) {
|
||||
LOG_WARN("modify group io config failed", K(ret), K(i));
|
||||
}
|
||||
}
|
||||
@ -1409,7 +1431,7 @@ int ObTenantIOManager::reset_consumer_group_config(const int64_t group_id)
|
||||
} else if (OB_UNLIKELY(index == INT64_MAX || index < 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid index, maybe try to reset OTHER_GROUPS or deleted_groups", K(ret), K(index), K(group_id));
|
||||
} else if (OB_FAIL(modify_group_io_config(index, 0, 0, 0, false, true/*cleared*/))) {
|
||||
} else if (OB_FAIL(modify_group_io_config(index, 0, 100, 0, false, true/*cleared*/))) {
|
||||
LOG_WARN("modify group io config failed", K(ret), K(tenant_id_), K(index));
|
||||
} else {
|
||||
LOG_INFO ("stop group io control success when delete directive", K(tenant_id_), K(group_id), K(index), K(io_config_));
|
||||
@ -1458,7 +1480,7 @@ int ObTenantIOManager::delete_consumer_group_config(const int64_t group_id)
|
||||
} else {
|
||||
if (OB_FAIL(group_id_index_map_.set_refactored(group_id, INT64_MAX, 1))) { //使用非法值覆盖
|
||||
LOG_WARN("stop phy queues failed", K(ret), K(tenant_id_), K(index));
|
||||
} else if (OB_FAIL(modify_group_io_config(index, 0, 0, 0, true/*deleted*/, false))) {
|
||||
} else if (OB_FAIL(modify_group_io_config(index, 0, 100, 0, true/*deleted*/, false))) {
|
||||
LOG_WARN("modify group io config failed", K(ret), K(tenant_id_), K(index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,6 +73,11 @@ public:
|
||||
int refresh_tenant_io_config(const uint64_t tenant_id, const ObTenantIOConfig &tenant_io_config);
|
||||
int get_tenant_io_manager(const uint64_t tenant_id, ObRefHolder<ObTenantIOManager> &tenant_holder);
|
||||
int get_tenant_ids(ObIArray<uint64_t> &tenant_ids);
|
||||
int modify_group_io_config(const uint64_t tenant_id,
|
||||
const uint64_t index,
|
||||
const int64_t min_percent,
|
||||
const int64_t max_percent,
|
||||
const int64_t weight_percent);
|
||||
ObIOScheduler *get_scheduler();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user