[FIX] updating throttle config when unit memory is changed

This commit is contained in:
ZenoWang
2024-02-08 09:00:19 +00:00
committed by ob-robot
parent bd483a08cc
commit cfd11df8fb
7 changed files with 77 additions and 45 deletions

View File

@ -1169,6 +1169,8 @@ int ObMultiTenant::update_tenant_memory(const ObUnitInfoGetter::ObTenantConfig &
LOG_WARN("fail to update tenant memory", K(ret), K(tenant_id)); LOG_WARN("fail to update tenant memory", K(ret), K(tenant_id));
} else if (OB_FAIL(update_tenant_freezer_mem_limit(tenant_id, memory_size, allowed_mem_limit))) { } else if (OB_FAIL(update_tenant_freezer_mem_limit(tenant_id, memory_size, allowed_mem_limit))) {
LOG_WARN("fail to update_tenant_freezer_mem_limit", K(ret), K(tenant_id)); LOG_WARN("fail to update_tenant_freezer_mem_limit", K(ret), K(tenant_id));
} else if (OB_FAIL(update_throttle_config_(tenant_id))) {
LOG_WARN("update throttle config failed", K(ret), K(tenant_id));
} else if (FALSE_IT(tenant->set_unit_memory_size(allowed_mem_limit))) { } else if (FALSE_IT(tenant->set_unit_memory_size(allowed_mem_limit))) {
// unreachable // unreachable
} }
@ -1309,8 +1311,8 @@ int ObMultiTenant::update_tenant_config(uint64_t tenant_id)
if (OB_TMP_FAIL(update_tenant_freezer_config_())) { if (OB_TMP_FAIL(update_tenant_freezer_config_())) {
LOG_WARN("failed to update tenant tenant freezer config", K(tmp_ret), K(tenant_id)); LOG_WARN("failed to update tenant tenant freezer config", K(tmp_ret), K(tenant_id));
} }
if (OB_TMP_FAIL(update_throttle_config_())) { if (OB_TMP_FAIL(update_throttle_config_(tenant_id))) {
LOG_WARN("update throttle config failed", K(ret), K(tenant_id));
} }
} }
} }
@ -1376,9 +1378,11 @@ int ObMultiTenant::update_tenant_freezer_config_()
return ret; return ret;
} }
int ObMultiTenant::update_throttle_config_() int ObMultiTenant::update_throttle_config_(const uint64_t tenant_id)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
MTL_SWITCH(tenant_id) {
ObSharedMemAllocMgr *share_mem_alloc_mgr = MTL(ObSharedMemAllocMgr *); ObSharedMemAllocMgr *share_mem_alloc_mgr = MTL(ObSharedMemAllocMgr *);
if (OB_ISNULL(share_mem_alloc_mgr)) { if (OB_ISNULL(share_mem_alloc_mgr)) {
@ -1387,6 +1391,7 @@ int ObMultiTenant::update_throttle_config_()
} else { } else {
(void)share_mem_alloc_mgr->update_throttle_config(); (void)share_mem_alloc_mgr->update_throttle_config();
} }
}
return ret; return ret;
} }

View File

@ -187,7 +187,7 @@ protected:
private: private:
int update_tenant_freezer_config_(); int update_tenant_freezer_config_();
int update_throttle_config_(); int update_throttle_config_(const uint64_t tenant_id);
protected: protected:
static const int DEL_TRY_TIMES = 30; static const int DEL_TRY_TIMES = 30;
enum class ObTenantCreateStep { enum class ObTenantCreateStep {

View File

@ -51,15 +51,23 @@ void ObSharedMemAllocMgr::update_throttle_config()
int64_t tx_data_limit = total_memory * tx_data_limit_percentage / 100LL; int64_t tx_data_limit = total_memory * tx_data_limit_percentage / 100LL;
int64_t mds_limit = total_memory * mds_limit_percentage / 100LL; int64_t mds_limit = total_memory * mds_limit_percentage / 100LL;
bool share_config_changed = false;
(void)share_resource_throttle_tool_.update_throttle_config<FakeAllocatorForTxShare>( (void)share_resource_throttle_tool_.update_throttle_config<FakeAllocatorForTxShare>(
share_mem_limit, trigger_percentage, max_duration); share_mem_limit, trigger_percentage, max_duration, share_config_changed);
(void)share_resource_throttle_tool_.update_throttle_config<ObMemstoreAllocator>(
memstore_limit, trigger_percentage, max_duration);
(void)share_resource_throttle_tool_.update_throttle_config<ObTenantTxDataAllocator>(
tx_data_limit, trigger_percentage, max_duration);
(void)share_resource_throttle_tool_.update_throttle_config<ObTenantMdsAllocator>(
mds_limit, trigger_percentage, max_duration);
bool memstore_config_changed = false;
(void)share_resource_throttle_tool_.update_throttle_config<ObMemstoreAllocator>(
memstore_limit, trigger_percentage, max_duration, memstore_config_changed);
bool tx_data_config_changed = false;
(void)share_resource_throttle_tool_.update_throttle_config<ObTenantTxDataAllocator>(
tx_data_limit, trigger_percentage, max_duration, tx_data_config_changed);
bool mds_config_changed = false;
(void)share_resource_throttle_tool_.update_throttle_config<ObTenantMdsAllocator>(
mds_limit, trigger_percentage, max_duration, mds_config_changed);
if (share_config_changed || memstore_config_changed || tx_data_config_changed || mds_config_changed) {
SHARE_LOG(INFO, SHARE_LOG(INFO,
"[Throttle] Update Config", "[Throttle] Update Config",
K(share_mem_limit_percentage), K(share_mem_limit_percentage),
@ -68,24 +76,35 @@ void ObSharedMemAllocMgr::update_throttle_config()
K(mds_limit_percentage), K(mds_limit_percentage),
K(trigger_percentage), K(trigger_percentage),
K(max_duration)); K(max_duration));
if (share_config_changed) {
SHARE_LOG(INFO, SHARE_LOG(INFO,
"[Throttle] Update Config", "[Throttle] Update Config",
THROTTLE_CONFIG_LOG(FakeAllocatorForTxShare, share_mem_limit, trigger_percentage, max_duration)); THROTTLE_CONFIG_LOG(FakeAllocatorForTxShare, share_mem_limit, trigger_percentage, max_duration));
}
if (memstore_config_changed) {
SHARE_LOG(INFO, SHARE_LOG(INFO,
"[Throttle] Update Config", "[Throttle] Update Config",
THROTTLE_CONFIG_LOG(ObMemstoreAllocator, memstore_limit, trigger_percentage, max_duration)); THROTTLE_CONFIG_LOG(ObMemstoreAllocator, memstore_limit, trigger_percentage, max_duration));
}
if (tx_data_config_changed) {
SHARE_LOG(INFO, SHARE_LOG(INFO,
"[Throttle] Update Config", "[Throttle] Update Config",
THROTTLE_CONFIG_LOG(ObTenantTxDataAllocator, tx_data_limit, trigger_percentage, max_duration)); THROTTLE_CONFIG_LOG(ObTenantTxDataAllocator, tx_data_limit, trigger_percentage, max_duration));
}
if (mds_config_changed) {
SHARE_LOG(INFO, SHARE_LOG(INFO,
"[Throttle] Update Config", "[Throttle] Update Config",
THROTTLE_CONFIG_LOG(ObTenantMdsAllocator, mds_limit, trigger_percentage, max_duration)); THROTTLE_CONFIG_LOG(ObTenantMdsAllocator, mds_limit, trigger_percentage, max_duration));
}
}
} else { } else {
SHARE_LOG_RET(WARN, OB_INVALID_CONFIG, "invalid tenant config", K(tenant_id), K(total_memory)); SHARE_LOG_RET(WARN, OB_INVALID_CONFIG, "invalid tenant config", K(tenant_id), K(total_memory));
} }
} }
#undef UPDATE_BY_CONFIG_NAME
} // namespace share } // namespace share
} // namespace oceanbase } // namespace oceanbase

View File

@ -109,7 +109,8 @@ public:
template <typename ALLOCATOR> template <typename ALLOCATOR>
void update_throttle_config(const int64_t resource_limit, void update_throttle_config(const int64_t resource_limit,
const int64_t trigger_percentage, const int64_t trigger_percentage,
const int64_t max_duration); const int64_t max_duration,
bool &config_changed);
template <typename ALLOCATOR> template <typename ALLOCATOR>
void enable_adaptive_limit(); void enable_adaptive_limit();

View File

@ -305,10 +305,11 @@ template <typename FakeAllocator, typename... Args>
template <typename ALLOCATOR> template <typename ALLOCATOR>
void ObShareResourceThrottleTool<FakeAllocator, Args...>::update_throttle_config(const int64_t resource_limit, void ObShareResourceThrottleTool<FakeAllocator, Args...>::update_throttle_config(const int64_t resource_limit,
const int64_t trigger_percentage, const int64_t trigger_percentage,
const int64_t max_duration) const int64_t max_duration,
bool &config_changed)
{ {
ACQUIRE_THROTTLE_UNIT(ALLOCATOR, throttle_unit); ACQUIRE_THROTTLE_UNIT(ALLOCATOR, throttle_unit);
(void)throttle_unit.update_throttle_config(resource_limit, trigger_percentage, max_duration); (void)throttle_unit.update_throttle_config(resource_limit, trigger_percentage, max_duration, config_changed);
} }
#undef ACQUIRE_THROTTLE_UNIT #undef ACQUIRE_THROTTLE_UNIT

View File

@ -153,7 +153,8 @@ public: // throttle configs setter
void set_resource_limit(const int64_t resource_limit); void set_resource_limit(const int64_t resource_limit);
void update_throttle_config(const int64_t resource_limit, void update_throttle_config(const int64_t resource_limit,
const int64_t throttle_trigger_percentage, const int64_t throttle_trigger_percentage,
const int64_t throttle_max_duration); const int64_t throttle_max_duration,
bool &config_changed);
private: private:
int get_throttle_info_(const ThrottleID &throttle_id, share::ObThrottleInfoGuard &ti_guard); int get_throttle_info_(const ThrottleID &throttle_id, share::ObThrottleInfoGuard &ti_guard);

View File

@ -474,8 +474,10 @@ void ObThrottleUnit<ALLOCATOR>::set_throttle_max_duration(const int64_t value)
template <typename ALLOCATOR> template <typename ALLOCATOR>
void ObThrottleUnit<ALLOCATOR>::update_throttle_config(const int64_t resource_limit, void ObThrottleUnit<ALLOCATOR>::update_throttle_config(const int64_t resource_limit,
const int64_t throttle_trigger_percentage, const int64_t throttle_trigger_percentage,
const int64_t throttle_max_duration) const int64_t throttle_max_duration,
bool &config_changed)
{ {
config_changed = false;
if (resource_limit < 0 || throttle_trigger_percentage <= 0 || throttle_trigger_percentage > 100 || if (resource_limit < 0 || throttle_trigger_percentage <= 0 || throttle_trigger_percentage > 100 ||
throttle_max_duration <= 0) { throttle_max_duration <= 0) {
int ret = OB_INVALID_ARGUMENT; int ret = OB_INVALID_ARGUMENT;
@ -484,7 +486,10 @@ void ObThrottleUnit<ALLOCATOR>::update_throttle_config(const int64_t resource_li
K(resource_limit), K(resource_limit),
K(throttle_trigger_percentage), K(throttle_trigger_percentage),
K(throttle_max_duration)); K(throttle_max_duration));
} else { } else if (config_specify_resource_limit_ != resource_limit ||
throttle_trigger_percentage_ != throttle_trigger_percentage ||
throttle_max_duration_ != throttle_max_duration) {
config_changed = true;
throttle_trigger_percentage_ = throttle_trigger_percentage; throttle_trigger_percentage_ = throttle_trigger_percentage;
throttle_max_duration_ = throttle_max_duration; throttle_max_duration_ = throttle_max_duration;
(void)inner_set_resource_limit_(resource_limit); (void)inner_set_resource_limit_(resource_limit);