提交 0a8815a6 编写于 作者: O obdev 提交者: ob-robot

[CP] Sql audit desige changed about mem_limit, queue_size and etc.

上级 4736d1b2
......@@ -44,36 +44,32 @@ int ObEliminateTask::init(const ObMySQLRequestManager* request_manager)
int ObEliminateTask::check_config_mem_limit(bool& is_change)
{
const int64_t MINIMUM_LIMIT = 64 * 1024 * 1024; // at lease 64M
const int64_t MAXIMUM_LIMIT = 1024 * 1024 * 1024; // 1G maximum
int ret = OB_SUCCESS;
is_change = false;
int64_t mem_limit = config_mem_limit_;
int64_t tenant_id = OB_INVALID_TENANT_ID;
if (OB_ISNULL(request_manager_)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(request_manager_), K(ret));
} else if (request_manager_->get_tenant_id() > OB_SYS_TENANT_ID &&
request_manager_->get_tenant_id() <= OB_MAX_RESERVED_TENANT_ID) {
} else if (FALSE_IT(tenant_id = request_manager_->get_tenant_id())) {
} else if (tenant_id > OB_SYS_TENANT_ID && tenant_id <= OB_MAX_RESERVED_TENANT_ID) {
// If the 50x tenant dosn't have a corresponding tenant schema,
// the query configuration must fail
} else if (OB_FAIL(ObMySQLRequestManager::get_mem_limit(request_manager_->get_tenant_id(), mem_limit))) {
LOG_WARN("failed to get mem limit", K(ret));
} else if (OB_FAIL(ObMySQLRequestManager::get_mem_limit(tenant_id, mem_limit))) {
// if memory limit is not retrivable
// overwrite error code, set mem config to default value
// so that total memory use of sql audit can be limited
// overwrite error code, not change the size of config_mem_limit_
LOG_WARN("failed to get mem limit", K(ret), K(tenant_id), K(mem_limit), K(config_mem_limit_));
ret = OB_SUCCESS;
mem_limit = MAXIMUM_LIMIT;
} else {
// do nothing
}
if (config_mem_limit_ != mem_limit) {
LOG_INFO("before change config mem", K(config_mem_limit_));
config_mem_limit_ = mem_limit;
if (mem_limit < MINIMUM_LIMIT && !lib::is_mini_mode()) {
config_mem_limit_ = MINIMUM_LIMIT;
if (config_mem_limit_ != mem_limit) {
LOG_INFO("change config mem limit", K(config_mem_limit_), K(mem_limit), K(tenant_id));
bool use_mini_mem = lib::is_mini_mode();
config_mem_limit_ = mem_limit;
if (mem_limit < MINIMUM_LIMIT && !use_mini_mem) {
config_mem_limit_ = MINIMUM_LIMIT;
}
is_change = true;
}
is_change = true;
LOG_INFO("after change config mem", K(config_mem_limit_));
}
return ret;
}
......@@ -147,7 +143,19 @@ void ObEliminateTask::runTimerTask()
ret = OB_NOT_INIT;
LOG_WARN("fail to get sql audit evict memory level", K(ret));
}
if (OB_SUCC(ret) && REACH_TIME_INTERVAL(30 * 1000 * 1000)) { // 30s delay
LOG_INFO("Eliminate task evict sql audit",
K(request_manager_->get_tenant_id()),
K(queue_size),
K(request_manager_->get_size_used()),
K(evict_high_size_level),
K(evict_low_size_level),
K(allocator->allocated()),
K(evict_high_mem_level),
K(evict_low_mem_level));
}
}
if (OB_SUCC(ret)) {
int64_t start_time = obsys::ObSysTimeUtil::getTime();
int64_t evict_batch_count = 0;
......
......@@ -257,12 +257,15 @@ int ObMySQLRequestManager::mtl_init(ObMySQLRequestManager*& req_mgr)
} else {
uint64_t tenant_id = lib::current_resource_owner_id();
int64_t mem_limit = lib::get_tenant_memory_limit(tenant_id);
int64_t queue_size = lib::is_mini_mode() ? MINI_MODE_MAX_QUEUE_SIZE : MAX_QUEUE_SIZE;
mem_limit = static_cast<int64_t>(static_cast<double>(mem_limit) * SQL_AUDIT_MEM_FACTOR);
bool use_mini_queue = lib::is_mini_mode();
int64_t queue_size = use_mini_queue ? MINI_MODE_MAX_QUEUE_SIZE : MAX_QUEUE_SIZE;
if (OB_FAIL(req_mgr->init(tenant_id, mem_limit, queue_size))) {
LOG_WARN("failed to init request manager", K(ret));
} else {
// do nothing
}
LOG_INFO("mtl init finish", K(tenant_id), K(mem_limit), K(queue_size), K(ret));
}
if (OB_FAIL(ret) && req_mgr != nullptr) {
// cleanup
......
......@@ -3813,7 +3813,7 @@ int ObSQLUtils::handle_audit_record(
/*do nothing*/
} else if (GCONF.enable_sql_audit) {
if (session.get_local_ob_enable_sql_audit()) {
FETCH_ENTITY(TENANT_SPACE, session.get_priv_tenant_id())
FETCH_ENTITY(TENANT_SPACE, session.get_effective_tenant_id())
{
ObMySQLRequestManager* req_manager = MTL_GET(ObMySQLRequestManager*);
if (nullptr == req_manager) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册