[CP] fix group_id_type_map update error
This commit is contained in:
3
deps/oblib/src/lib/worker.cpp
vendored
3
deps/oblib/src/lib/worker.cpp
vendored
@ -44,9 +44,10 @@ int __attribute__((weak)) common_yield()
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) SET_GROUP_ID(uint64_t group_id)
|
||||
int __attribute__((weak)) SET_GROUP_ID(uint64_t group_id, bool is_background)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(is_background);
|
||||
THIS_WORKER.set_group_id_(group_id);
|
||||
return ret;
|
||||
}
|
||||
|
4
deps/oblib/src/lib/worker.h
vendored
4
deps/oblib/src/lib/worker.h
vendored
@ -202,7 +202,7 @@ inline Worker &this_worker()
|
||||
#define GET_FUNC_TYPE() (THIS_WORKER.get_func_type())
|
||||
#define GET_GROUP_ID() (THIS_WORKER.get_group_id())
|
||||
|
||||
int SET_GROUP_ID(uint64_t group_id);
|
||||
int SET_GROUP_ID(uint64_t group_id, bool is_background = false);
|
||||
|
||||
int CONVERT_FUNCTION_TYPE_TO_GROUP_ID(const uint8_t function_type, uint64_t &group_id);
|
||||
|
||||
@ -246,7 +246,7 @@ public:
|
||||
ret_ = CONVERT_FUNCTION_TYPE_TO_GROUP_ID(func_type, group_id);
|
||||
if (OB_SUCCESS == ret_ && is_user_group(group_id) && group_id != thread_group_id_) {
|
||||
group_changed_ = true;
|
||||
ret_ = SET_GROUP_ID(group_id);
|
||||
ret_ = SET_GROUP_ID(group_id, true /* is_background */);
|
||||
}
|
||||
}
|
||||
~ConsumerGroupFuncGuard()
|
||||
|
@ -279,8 +279,6 @@ public:
|
||||
int64_t min_worker_cnt() const;
|
||||
int64_t max_worker_cnt() const;
|
||||
ObTenant *get_tenant() { return tenant_; }
|
||||
WList &get_workers() { return workers_; }
|
||||
lib::ObMutex &get_workers_lock() { return workers_lock_; }
|
||||
share::ObCgroupCtrl *get_cgroup_ctrl() { return cgroup_ctrl_; }
|
||||
bool is_job_group(int64_t group_id) { return share::OBCG_OLAP_ASYNC_JOB == group_id; }
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace oceanbase
|
||||
namespace lib
|
||||
{
|
||||
|
||||
int SET_GROUP_ID(uint64_t group_id)
|
||||
int SET_GROUP_ID(uint64_t group_id, bool is_background)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -47,7 +47,7 @@ int SET_GROUP_ID(uint64_t group_id)
|
||||
THIS_WORKER.set_group_id_(group_id);
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_NOT_NULL(GCTX.cgroup_ctrl_)
|
||||
&& OB_TMP_FAIL(GCTX.cgroup_ctrl_->add_self_to_cgroup_(MTL_ID(), group_id))) {
|
||||
&& OB_TMP_FAIL(GCTX.cgroup_ctrl_->add_self_to_cgroup_(MTL_ID(), group_id, is_background))) {
|
||||
LOG_WARN("add self to cgroup fail", K(ret), K(MTL_ID()), K(group_id));
|
||||
}
|
||||
return ret;
|
||||
@ -397,24 +397,13 @@ int ObCgroupCtrl::get_group_path(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCgroupCtrl::add_self_to_cgroup_(const uint64_t tenant_id, const uint64_t group_id)
|
||||
int ObCgroupCtrl::add_self_to_cgroup_(const uint64_t tenant_id, const uint64_t group_id, const bool is_background)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (is_valid()) {
|
||||
ResourceGroupType group_type = ResourceGroupType::INVALID_GROUP;
|
||||
if (is_user_group(group_id) &&
|
||||
OB_FAIL(G_RES_MGR.get_mapping_rule_mgr().get_group_type_by_id(tenant_id, group_id, group_type))) {
|
||||
if (OB_HASH_NOT_EXIST == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("get group type by id failed", K(ret), K(tenant_id), K(group_id), K(group_type));
|
||||
}
|
||||
}
|
||||
|
||||
const char *base_path =
|
||||
(GCONF.enable_global_background_resource_isolation && ResourceGroupType::FUNCTION_GROUP == group_type)
|
||||
? BACKGROUND_CGROUP
|
||||
: "";
|
||||
(GCONF.enable_global_background_resource_isolation && is_background) ? BACKGROUND_CGROUP : "";
|
||||
char group_path[PATH_BUFSIZE];
|
||||
char tid_value[VALUE_BUFSIZE + 1];
|
||||
|
||||
|
@ -211,8 +211,8 @@ private:
|
||||
|
||||
private:
|
||||
friend class oceanbase::share::ObTenantBase;
|
||||
friend int oceanbase::lib::SET_GROUP_ID(uint64_t group_id);
|
||||
int add_self_to_cgroup_(const uint64_t tenant_id, const uint64_t group_id = OBCG_DEFAULT);
|
||||
friend int oceanbase::lib::SET_GROUP_ID(uint64_t group_id, bool is_background);
|
||||
int add_self_to_cgroup_(const uint64_t tenant_id, const uint64_t group_id = OBCG_DEFAULT, const bool is_background = false);
|
||||
int init_cgroup_root_dir_(const char *cgroup_path);
|
||||
static int init_dir_(const char *curr_dir);
|
||||
static int init_full_dir_(const char *curr_path);
|
||||
|
@ -27,7 +27,7 @@ int ObResourceMappingRuleManager::init()
|
||||
int rule_bucket_size = 4096;
|
||||
int group_bucket_size = 512;
|
||||
if (user_rule_map_.created() || group_id_name_map_.created() ||
|
||||
function_rule_map_.created() || group_name_id_map_.created() || group_id_type_map_.created()) {
|
||||
function_rule_map_.created() || group_name_id_map_.created()) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("mapping rule manager should not init multiple times", K(ret));
|
||||
} else if (OB_FAIL(user_rule_map_.create(rule_bucket_size, "UsrRuleMap", "UsrRuleMapNode"))) {
|
||||
@ -40,7 +40,7 @@ int ObResourceMappingRuleManager::init()
|
||||
LOG_WARN("fail create function rule map", K(ret));
|
||||
} else if (OB_FAIL(group_name_id_map_.create(group_bucket_size, "GrpNameIdMap", "GrpNameIdNode"))) {
|
||||
LOG_WARN("fail create name id map", K(ret));
|
||||
} else if (OB_FAIL(group_id_type_map_.create(group_bucket_size, "GrpIdTypeMap", "GrpIdTypeNode")))
|
||||
}
|
||||
LOG_INFO("resource mapping rule manager init ok");
|
||||
return ret;
|
||||
}
|
||||
@ -155,10 +155,6 @@ int ObResourceMappingRuleManager::refresh_resource_user_mapping_rule(
|
||||
1 /* overwrite on dup key */))) {
|
||||
LOG_WARN("fail set user mapping rule to rule_map", K(rule), K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret) && OB_FAIL(group_id_type_map_.set_refactored(
|
||||
share::ObTenantGroupIdKey(rule.tenant_id_, group_id), ResourceGroupType::USER_GROUP))) {
|
||||
LOG_WARN("group_id_type_map_ set_refactored failed", K(ret), K(group_id));
|
||||
}
|
||||
}
|
||||
LOG_INFO("refresh resource user mapping rule", K(tenant_id), K(plan), K(user_rules));
|
||||
}
|
||||
@ -196,10 +192,6 @@ int ObResourceMappingRuleManager::refresh_resource_function_mapping_rule(
|
||||
1 /* overwrite on dup key */))) {
|
||||
LOG_WARN("fail set user mapping rule to rule_map", K(rule), K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret) && OB_FAIL(group_id_type_map_.set_refactored(
|
||||
share::ObTenantGroupIdKey(rule.tenant_id_, group_id), ResourceGroupType::FUNCTION_GROUP))) {
|
||||
LOG_WARN("group_id_type_map_ set_refactored failed", K(ret), K(group_id));
|
||||
}
|
||||
}
|
||||
LOG_INFO("refresh_resource_function_mapping_rule", K(tenant_id), K(plan), K(rules));
|
||||
}
|
||||
|
@ -29,15 +29,6 @@ class ObString;
|
||||
}
|
||||
namespace share
|
||||
{
|
||||
|
||||
enum class ResourceGroupType {
|
||||
INVALID_GROUP,
|
||||
USER_GROUP,
|
||||
FUNCTION_GROUP,
|
||||
SQL_GROUP,
|
||||
END_GROUP
|
||||
};
|
||||
|
||||
class ObResourceManagerProxy;
|
||||
class ObResourceMappingRuleManager
|
||||
{
|
||||
@ -135,11 +126,7 @@ public:
|
||||
int ret = function_rule_map_.set_refactored(share::ObTenantFunctionKey(tenant_id, func), 0, 1/*overwrite*/);
|
||||
return ret;
|
||||
}
|
||||
inline int get_group_type_by_id(const uint64_t tenant_id, uint64_t group_id, ResourceGroupType &group_type)
|
||||
{
|
||||
int ret = group_id_type_map_.get_refactored(share::ObTenantGroupIdKey(tenant_id, group_id), group_type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
int refresh_resource_function_mapping_rule(
|
||||
ObResourceManagerProxy &proxy,
|
||||
@ -159,7 +146,6 @@ private:
|
||||
common::hash::ObHashMap<uint64_t, ObGroupName> group_id_name_map_;
|
||||
// 将 group_name 映射到 group_id, 用于快速根据group_name找到id(主要是用于io控制)
|
||||
common::hash::ObHashMap<share::ObTenantGroupKey, uint64_t> group_name_id_map_;
|
||||
common::hash::ObHashMap<share::ObTenantGroupIdKey, ResourceGroupType> group_id_type_map_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObResourceMappingRuleManager);
|
||||
};
|
||||
}
|
||||
|
@ -157,54 +157,6 @@ public:
|
||||
ObResMgrVarcharValue func_name_;
|
||||
};
|
||||
|
||||
// ObTenantGroupIdKey
|
||||
class ObTenantGroupIdKey {
|
||||
public:
|
||||
ObTenantGroupIdKey() : tenant_id_(OB_INVALID_TENANT_ID), group_id_(OB_INVALID_ID)
|
||||
{}
|
||||
ObTenantGroupIdKey(const uint64_t tenant_id, const uint64_t group_id) :
|
||||
tenant_id_(tenant_id), group_id_(group_id)
|
||||
{}
|
||||
int assign(const ObTenantGroupIdKey &other)
|
||||
{
|
||||
tenant_id_ = other.tenant_id_;
|
||||
group_id_ = other.group_id_;
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
uint64_t hash() const
|
||||
{
|
||||
uint64_t hash_val = 0;
|
||||
hash_val = common::murmurhash(&tenant_id_, sizeof(tenant_id_), hash_val);
|
||||
hash_val = common::murmurhash(&group_id_, sizeof(group_id_), hash_val);
|
||||
return hash_val;
|
||||
}
|
||||
int hash(uint64_t &hash_val) const
|
||||
{
|
||||
hash_val = hash();
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
int compare(const ObTenantGroupIdKey& r) const
|
||||
{
|
||||
int cmp = 0;
|
||||
if (tenant_id_ < r.tenant_id_) {
|
||||
cmp = -1;
|
||||
} else if (tenant_id_ == r.tenant_id_) {
|
||||
cmp = group_id_ < r.group_id_ ? -1 : (group_id_ > r.group_id_ ? 1 : 0);
|
||||
} else {
|
||||
cmp = 1;
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
bool operator== (const ObTenantGroupIdKey &other) const { return 0 == compare(other); }
|
||||
bool operator!=(const ObTenantGroupIdKey &other) const { return !operator==(other); }
|
||||
bool operator<(const ObTenantGroupIdKey &other) const { return -1 == compare(other); }
|
||||
TO_STRING_KV(K_(tenant_id), K_(group_id));
|
||||
|
||||
public:
|
||||
uint64_t tenant_id_;
|
||||
uint64_t group_id_;
|
||||
};
|
||||
|
||||
class ObPlanDirective
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user