提交 daa17789 编写于 作者: L LINxiansheng 提交者: wangzelin.wzl

fix a bug about show query_response_time

上级 81ddf033
...@@ -137,10 +137,10 @@ int ObRSTCollector::collect_query_response_time(uint64_t tenant_id, uint64_t tim ...@@ -137,10 +137,10 @@ int ObRSTCollector::collect_query_response_time(uint64_t tenant_id, uint64_t tim
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id));
if(tenant_config->query_response_time_stats){ if(tenant_config->query_response_time_stats){
ObRSTTimeCollector* time_collector; ObRSTTimeCollector* time_collector;
if (OB_FAIL(ret = collector_map_.get_refactored(tenant_id, time_collector))){ if (OB_FAIL(collector_map_.get_refactored(tenant_id, time_collector))){
SERVER_LOG(WARN, "time collector of the tenant does not exist", K(tenant_id), K(time), K(ret)); SERVER_LOG(WARN, "time collector of the tenant does not exist", K(tenant_id), K(time), K(ret));
} else { } else {
if(OB_FAIL(ret = time_collector->collect(time))){ if(OB_FAIL(time_collector->collect(time))){
SERVER_LOG(WARN, "time collector of the tenant collect time failed", K(tenant_id), K(time), K(ret)); SERVER_LOG(WARN, "time collector of the tenant collect time failed", K(tenant_id), K(time), K(ret));
} }
} }
...@@ -159,15 +159,15 @@ int ObRSTCollector::flush_query_response_time(uint64_t tenant_id,const ObString& ...@@ -159,15 +159,15 @@ int ObRSTCollector::flush_query_response_time(uint64_t tenant_id,const ObString&
SERVER_LOG(WARN, "invalid bool str", K(ret), K(is_enable), K(tenant_id)); SERVER_LOG(WARN, "invalid bool str", K(ret), K(is_enable), K(tenant_id));
} else if (is_enable_value) { } else if (is_enable_value) {
ObRSTTimeCollector* time_collector; ObRSTTimeCollector* time_collector;
if (OB_FAIL(ret = collector_map_.get_refactored(tenant_id, time_collector))){ if (!tenant_config->query_response_time_stats){
SERVER_LOG(WARN, "query_response_time_stats already turn off", K(ret), K(tenant_id));
} else if (OB_FAIL(collector_map_.get_refactored(tenant_id, time_collector))){
SERVER_LOG(WARN, "time collector of the tenant does not exist", K(ret), K(tenant_id)); SERVER_LOG(WARN, "time collector of the tenant does not exist", K(ret), K(tenant_id));
} else { } else if (OB_FAIL(time_collector->setup(tenant_config->query_response_time_range_base))){
if (OB_FAIL(ret = time_collector->setup(tenant_config->query_response_time_range_base))){ SERVER_LOG(WARN, "time collector of the tenant set range base failed", K(ret), K(tenant_id));
SERVER_LOG(WARN, "time collector of the tenant set range base failed", K(ret), K(tenant_id)); } else if (OB_FAIL(time_collector->flush())){
} else if (OB_FAIL(ret = time_collector->flush())){ SERVER_LOG(WARN, "time collector of the tenant flush failed", K(ret), K(tenant_id));
SERVER_LOG(WARN, "time collector of the tenant flush failed", K(ret), K(tenant_id)); }
}
}
} }
return ret; return ret;
} }
...@@ -177,7 +177,7 @@ int ObRSTCollector::enable_query_response_time(uint64_t tenant_id){ ...@@ -177,7 +177,7 @@ int ObRSTCollector::enable_query_response_time(uint64_t tenant_id){
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id));
if(tenant_config->query_response_time_stats){ if(tenant_config->query_response_time_stats){
SERVER_LOG(INFO, "query_response_time_stats already turn on", K(ret), K(tenant_id)); SERVER_LOG(INFO, "query_response_time_stats already turn on", K(ret), K(tenant_id));
} else if (OB_FAIL(ret = collector_map_.set_refactored(tenant_id, new ObRSTTimeCollector()))) { } else if (OB_FAIL(collector_map_.set_refactored(tenant_id, new ObRSTTimeCollector()))) {
if (OB_HASH_EXIST == ret) { if (OB_HASH_EXIST == ret) {
ret = OB_ERR_ALREADY_EXISTS; ret = OB_ERR_ALREADY_EXISTS;
} }
...@@ -188,9 +188,7 @@ int ObRSTCollector::enable_query_response_time(uint64_t tenant_id){ ...@@ -188,9 +188,7 @@ int ObRSTCollector::enable_query_response_time(uint64_t tenant_id){
int ObRSTCollector::free_query_response_time(uint64_t tenant_id){ int ObRSTCollector::free_query_response_time(uint64_t tenant_id){
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id));
if(!tenant_config->query_response_time_stats){ if (OB_FAIL(collector_map_.erase_refactored(tenant_id))) {
SERVER_LOG(INFO, "query_response_time_stats already turn off", K(ret), K(tenant_id));
} else if (OB_FAIL(collector_map_.erase_refactored(tenant_id))) {
SERVER_LOG(WARN,"erase the time collector failed", K(tenant_id)); SERVER_LOG(WARN,"erase the time collector failed", K(tenant_id));
} }
return ret; return ret;
...@@ -202,10 +200,10 @@ int ObRSTCollector::control_query_response_time(uint64_t tenant_id, const ObStri ...@@ -202,10 +200,10 @@ int ObRSTCollector::control_query_response_time(uint64_t tenant_id, const ObStri
bool is_valid = false; bool is_valid = false;
is_enable_value = ObConfigBoolParser::get(is_enable.ptr(), is_valid); is_enable_value = ObConfigBoolParser::get(is_enable.ptr(), is_valid);
if (is_enable_value) { if (is_enable_value) {
if (OB_FAIL(ret = enable_query_response_time(tenant_id))){ if (OB_FAIL(enable_query_response_time(tenant_id))){
SERVER_LOG(WARN, "enable the query response time failed", K(ret),K(tenant_id)); SERVER_LOG(WARN, "enable the query response time failed", K(ret),K(tenant_id));
} }
} else if (OB_FAIL(ret = free_query_response_time(tenant_id))){ } else if (OB_FAIL(free_query_response_time(tenant_id))){
SERVER_LOG(WARN, "free the query response time failed", K(ret),K(tenant_id)); SERVER_LOG(WARN, "free the query response time failed", K(ret),K(tenant_id));
} }
return ret; return ret;
......
...@@ -1113,7 +1113,8 @@ int ObShowResolver::resolve(const ParseNode& parse_tree) ...@@ -1113,7 +1113,8 @@ int ObShowResolver::resolve(const ParseNode& parse_tree)
} else { } else {
show_resv_ctx.stmt_type_ = stmt::T_SHOW_QUERY_RESPONSE_TIME; show_resv_ctx.stmt_type_ = stmt::T_SHOW_QUERY_RESPONSE_TIME;
GEN_SQL_STEP_1(ObShowSqlSet::SHOW_QUERY_RESPONSE_TIME); GEN_SQL_STEP_1(ObShowSqlSet::SHOW_QUERY_RESPONSE_TIME);
GEN_SQL_STEP_2(ObShowSqlSet::SHOW_QUERY_RESPONSE_TIME, OB_SYS_DATABASE_NAME, OB_ALL_VIRTUAL_QUERY_RESPONSE_TIME_TNAME); GEN_SQL_STEP_2(ObShowSqlSet::SHOW_QUERY_RESPONSE_TIME,
OB_SYS_DATABASE_NAME, OB_ALL_VIRTUAL_QUERY_RESPONSE_TIME_TNAME, real_tenant_id);
} }
break; break;
} }
...@@ -2081,7 +2082,8 @@ DEFINE_SHOW_CLAUSE_SET(SHOW_ENGINES, NULL, "SELECT * FROM %s.%s ", NULL, NULL); ...@@ -2081,7 +2082,8 @@ DEFINE_SHOW_CLAUSE_SET(SHOW_ENGINES, NULL, "SELECT * FROM %s.%s ", NULL, NULL);
DEFINE_SHOW_CLAUSE_SET(SHOW_PRIVILEGES, NULL, "SELECT * FROM %s.%s ", "SELECT * FROM %s.%s ", NULL); DEFINE_SHOW_CLAUSE_SET(SHOW_PRIVILEGES, NULL, "SELECT * FROM %s.%s ", "SELECT * FROM %s.%s ", NULL);
DEFINE_SHOW_CLAUSE_SET(SHOW_QUERY_RESPONSE_TIME, NULL, "SELECT * FROM %s.%s ", NULL, NULL); DEFINE_SHOW_CLAUSE_SET(SHOW_QUERY_RESPONSE_TIME, NULL,
"SELECT response_time as RESPONSE_TIME, count as COUNT, total as TOTAL FROM %s.%s where tenant_id = %lu", NULL, NULL);
DEFINE_SHOW_CLAUSE_SET(SHOW_COLLATION, NULL, DEFINE_SHOW_CLAUSE_SET(SHOW_COLLATION, NULL,
"SELECT collation AS `Collation`, charset AS `Charset`, id AS `Id`, is_default AS `Default`, is_compiled AS " "SELECT collation AS `Collation`, charset AS `Charset`, id AS `Id`, is_default AS `Default`, is_compiled AS "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册