Make enable_system_tenant_memory_limit take effect dynamicly
This commit is contained in:
parent
76134a4ff4
commit
0acbec120f
@ -403,7 +403,7 @@ int ObMallocAllocator::with_resource_handle_invoke(uint64_t tenant_id, InvokeFun
|
||||
return ret;
|
||||
}
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
int ObMallocAllocator::set_500_tenant_limit()
|
||||
int ObMallocAllocator::set_500_tenant_limit(const bool unlimited)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int ctx_id = 0; OB_SUCC(ret) && ctx_id < ObCtxIds::MAX_CTX_ID; ++ctx_id) {
|
||||
@ -420,6 +420,9 @@ int ObMallocAllocator::set_500_tenant_limit()
|
||||
auto ta = get_tenant_ctx_allocator(OB_SERVER_TENANT_ID, ctx_id);
|
||||
if (OB_NOT_NULL(ta)) {
|
||||
int64_t ctx_limit = ObCtxIds::DEFAULT_CTX_ID == ctx_id ? (3LL<<30) : (50LL<<20);
|
||||
if (unlimited) {
|
||||
ctx_limit = INT64_MAX;
|
||||
}
|
||||
if (OB_FAIL(ta->set_limit(ctx_limit))) {
|
||||
LIB_LOG(WARN, "set limit of 500 tenant failed", K(ret), K(ctx_limit),
|
||||
"ctx_name", get_global_ctx_info().get_ctx_name(ctx_id));
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
void set_reserved(int64_t bytes);
|
||||
int64_t get_reserved() const;
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
int set_500_tenant_limit();
|
||||
int set_500_tenant_limit(const bool unlimited);
|
||||
#endif
|
||||
int set_tenant_limit(uint64_t tenant_id, int64_t bytes);
|
||||
int64_t get_tenant_limit(uint64_t tenant_id);
|
||||
|
@ -139,6 +139,7 @@ static constexpr const char *usage_str =
|
||||
"{{row1}, {row2}, ...} = select_schema_slot()\n"
|
||||
"{{row1}, {row2}, ...} = dump_thread_info()\n"
|
||||
"{{row1}, {row2}, ...} = select_malloc_sample_info()\n"
|
||||
"int = enable_system_tenant_memory_limit(boolean)\n"
|
||||
;
|
||||
|
||||
class LuaVtableGenerator
|
||||
@ -1986,6 +1987,28 @@ int select_malloc_sample_info(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// int = enable_system_tenant_memory_limit(boolean)
|
||||
int enable_system_tenant_memory_limit(lua_State* L)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int argc = lua_gettop(L);
|
||||
if (1 != argc) {
|
||||
OB_LOG(ERROR, "call enable_system_tenant_memory_limit() failed, bad arguments count, should be 1.");
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
} else {
|
||||
luaL_checktype(L, 1, LUA_TBOOLEAN);
|
||||
int enable = lua_toboolean(L, 1);
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
ObMallocAllocator::get_instance()->set_500_tenant_limit(!enable/*unlimited*/);
|
||||
#endif
|
||||
lua_pushinteger(L, 1);
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
lua_pushinteger(L, -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// API end
|
||||
|
||||
int get_tenant_sysstat(int64_t tenant_id, int64_t statistic, int64_t &value)
|
||||
@ -2113,6 +2136,7 @@ void APIRegister::register_api(lua_State* L)
|
||||
lua_register(L, "select_schema_slot", select_schema_slot);
|
||||
lua_register(L, "dump_thread_info", dump_thread_info);
|
||||
lua_register(L, "select_malloc_sample_info", select_malloc_sample_info);
|
||||
lua_register(L, "enable_system_tenant_memory_limit", enable_system_tenant_memory_limit);
|
||||
}
|
||||
|
||||
int APIRegister::flush()
|
||||
|
@ -336,4 +336,6 @@ para["select"] = {
|
||||
"alloc_bytes"
|
||||
}
|
||||
print_to_client("select_malloc_sample_info")
|
||||
select_malloc_sample_info(para)
|
||||
select_malloc_sample_info(para)
|
||||
|
||||
enable_system_tenant_memory_limit(true)
|
||||
|
@ -1717,11 +1717,6 @@ int ObServer::init_config()
|
||||
LOG_ERROR("some config setting is not valid", KR(ret));
|
||||
} else if (OB_FAIL(GMEMCONF.reload_config(config_))) {
|
||||
LOG_ERROR("reload memory config failed", KR(ret));
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
} else if (config_._enable_system_tenant_memory_limit &&
|
||||
OB_FAIL(ObMallocAllocator::get_instance()->set_500_tenant_limit())) {
|
||||
LOG_ERROR("set the limit of tenant 500 failed", KR(ret));
|
||||
#endif
|
||||
} else if (!is_arbitration_mode() && OB_FAIL(set_running_mode())) {
|
||||
LOG_ERROR("set running mode failed", KR(ret));
|
||||
} else {
|
||||
|
@ -287,6 +287,17 @@ int ObServerMemoryConfig::reload_config(const ObServerConfig& server_config)
|
||||
K(observer_tenant_hold), K_(system_memory));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
if (OB_FAIL(ret)) {
|
||||
// do-nothing
|
||||
} else if (is_arbitration_mode) {
|
||||
// do-nothing
|
||||
} else if (OB_FAIL(ObMallocAllocator::get_instance()->set_500_tenant_limit(
|
||||
!server_config._enable_system_tenant_memory_limit))) {
|
||||
LOG_ERROR("set the limit of tenant 500 failed", KR(ret));
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1573,5 +1573,5 @@ DEF_CAP(range_optimizer_max_mem_size, OB_TENANT_PARAMETER, "128M", "[16M,1G]",
|
||||
#ifdef ENABLE_500_MEMORY_LIMIT
|
||||
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::STATIC_EFFECTIVE));
|
||||
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user