fix dynamic_worker not working

This commit is contained in:
nroskill 2023-07-03 07:42:21 +00:00 committed by ob-robot
parent d3dcf6934d
commit 5e3df6523d
3 changed files with 12 additions and 4 deletions

View File

@ -376,9 +376,11 @@ void ObResourceGroup::check_worker_count()
int64_t token = 1;
int64_t now = ObTimeUtility::current_time();
bool enable_dynamic_worker = true;
int64_t threshold = 3 * 1000;
{
ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_->id()));
enable_dynamic_worker = tenant_config.is_valid() ? tenant_config->_ob_enable_dynamic_worker : true;
threshold = tenant_config.is_valid() ? tenant_config->_worker_long_stall_threshold : 3 * 1000;
}
DLIST_FOREACH_REMOVESAFE(wnode, workers_) {
const auto w = static_cast<ObThWorker*>(wnode->get_data());
@ -386,7 +388,7 @@ void ObResourceGroup::check_worker_count()
workers_.remove(wnode);
destroy_worker(w);
} else if (w->has_req_flag()
&& w->blocking_ts() - now >= EXPAND_INTERVAL
&& now - w->blocking_ts() >= threshold
&& enable_dynamic_worker) {
++token;
}
@ -1370,9 +1372,11 @@ void ObTenant::check_worker_count()
int64_t token = 3;
int64_t now = ObTimeUtility::current_time();
bool enable_dynamic_worker = true;
int64_t threshold = 3 * 1000;
{
ObTenantConfigGuard tenant_config(TENANT_CONF(id_));
enable_dynamic_worker = tenant_config.is_valid() ? tenant_config->_ob_enable_dynamic_worker : true;
threshold = tenant_config.is_valid() ? tenant_config->_worker_long_stall_threshold : 3 * 1000;
}
// assume that high priority and normal priority were busy.
DLIST_FOREACH_REMOVESAFE(wnode, workers_) {
@ -1381,7 +1385,7 @@ void ObTenant::check_worker_count()
workers_.remove(wnode);
destroy_worker(w);
} else if (w->has_req_flag()
&& w->blocking_ts() - now >= EXPAND_INTERVAL
&& now - w->blocking_ts() >= threshold
&& w->is_default_worker()
&& enable_dynamic_worker) {
++token;

View File

@ -317,8 +317,8 @@ DEF_INT(_ob_max_thread_num, OB_CLUSTER_PARAMETER, "0", "[0,10000)",
"ob max thread number "
"upper limit of observer thread count. Range: [0, 10000), 0 means no limit.",
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_DBL(cpu_quota_concurrency, OB_TENANT_PARAMETER, "4", "[1,10]",
"max allowed concurrency for 1 CPU quota. Range: [1,10]",
DEF_DBL(cpu_quota_concurrency, OB_TENANT_PARAMETER, "4", "[1,20]",
"max allowed concurrency for 1 CPU quota. Range: [1,20]",
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_DBL(token_reserved_percentage, OB_CLUSTER_PARAMETER,
"30", "[0,100]",
@ -1575,3 +1575,6 @@ DEF_BOOL(_enable_system_tenant_memory_limit, OB_CLUSTER_PARAMETER, "True",
"specifies whether allowed to limit the memory of tenant 500",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
#endif
DEF_TIME(_worker_long_stall_threshold, OB_TENANT_PARAMETER, "3ms", "[0ms,)",
"threshold of dynamic worker works",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));

View File

@ -372,6 +372,7 @@ _tx_result_retention
_upgrade_stage
_wait_interval_after_truncate
_with_subquery
_worker_long_stall_threshold
_xa_gc_interval
_xa_gc_timeout
_xsolapi_generate_with_clause