fix gather truncate longtext string bug and write opt stats gather history bug
This commit is contained in:
@ -139,11 +139,7 @@ int ObDbmsStats::gather_table_stats(ObExecContext &ctx, ParamStore ¶ms, ObOb
|
|||||||
task_info.task_end_time_ = ObTimeUtility::current_time();
|
task_info.task_end_time_ = ObTimeUtility::current_time();
|
||||||
task_info.ret_code_ = ret;
|
task_info.ret_code_ = ret;
|
||||||
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : 1;
|
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : 1;
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
update_optimizer_gather_stat_info(&task_info, &gather_stat);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_task_stat(task_info);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_gather_stat(gather_stat);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
ObOptStatGatherStatList::instance().remove(gather_stat);
|
ObOptStatGatherStatList::instance().remove(gather_stat);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -266,20 +262,14 @@ int ObDbmsStats::gather_schema_stats(ObExecContext &ctx, ParamStore ¶ms, ObO
|
|||||||
LOG_TRACE("Succeed to gather table stats", K(stat_param), K(running_monitor));
|
LOG_TRACE("Succeed to gather table stats", K(stat_param), K(running_monitor));
|
||||||
}
|
}
|
||||||
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), stat_param.allocator_->used());
|
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), stat_param.allocator_->used());
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
update_optimizer_gather_stat_info(NULL, &gather_stat);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_gather_stat(gather_stat);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
ObOptStatGatherStatList::instance().remove(gather_stat);
|
ObOptStatGatherStatList::instance().remove(gather_stat);
|
||||||
task_info.completed_table_count_ ++;
|
task_info.completed_table_count_ ++;
|
||||||
}
|
}
|
||||||
task_info.task_end_time_ = ObTimeUtility::current_time();
|
task_info.task_end_time_ = ObTimeUtility::current_time();
|
||||||
task_info.ret_code_ = ret;
|
task_info.ret_code_ = ret;
|
||||||
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : table_ids.count() - i + 1;
|
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : table_ids.count() - i + 1;
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
update_optimizer_gather_stat_info(&task_info, NULL);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_task_stat(task_info);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5359,10 +5349,7 @@ int ObDbmsStats::gather_database_stats_job_proc(sql::ObExecContext &ctx,
|
|||||||
ret = ret == OB_TIMEOUT ? OB_SUCCESS : ret;
|
ret = ret == OB_TIMEOUT ? OB_SUCCESS : ret;
|
||||||
task_info.task_end_time_ = ObTimeUtility::current_time();
|
task_info.task_end_time_ = ObTimeUtility::current_time();
|
||||||
task_info.ret_code_ = ret;
|
task_info.ret_code_ = ret;
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
update_optimizer_gather_stat_info(&task_info, NULL);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_task_stat(task_info);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5708,10 +5695,7 @@ int ObDbmsStats::gather_table_stats_with_default_param(ObExecContext &ctx,
|
|||||||
LOG_TRACE("Succeed to gather table stats", K(stat_param));
|
LOG_TRACE("Succeed to gather table stats", K(stat_param));
|
||||||
}
|
}
|
||||||
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), stat_param.allocator_->used());
|
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), stat_param.allocator_->used());
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
update_optimizer_gather_stat_info(NULL, &gather_stat);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_gather_stat(gather_stat);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
ObOptStatGatherStatList::instance().remove(gather_stat);
|
ObOptStatGatherStatList::instance().remove(gather_stat);
|
||||||
task_info.completed_table_count_ ++;
|
task_info.completed_table_count_ ++;
|
||||||
return ret;
|
return ret;
|
||||||
@ -6725,5 +6709,30 @@ bool ObDbmsStats::is_partition_no_regather(int64_t part_id,
|
|||||||
return is_true;
|
return is_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObDbmsStats::update_optimizer_gather_stat_info(const ObOptStatTaskInfo *task_info,
|
||||||
|
const ObOptStatGatherStat *gather_stat)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
||||||
|
int64_t origin_timeout = THIS_WORKER.get_timeout_ts();
|
||||||
|
THIS_WORKER.set_session(NULL);
|
||||||
|
const int64_t MAX_UPDATE_OPT_GATHER_STAT_TIMEOUT = 10000000;//default 10 seconds
|
||||||
|
THIS_WORKER.set_timeout_ts(MAX_UPDATE_OPT_GATHER_STAT_TIMEOUT + ObTimeUtility::current_time());
|
||||||
|
if (task_info != NULL) {
|
||||||
|
if (OB_FAIL(ObOptStatManager::get_instance().update_opt_stat_task_stat(*task_info))) {
|
||||||
|
LOG_WARN("failed to update opt stat task stat", K(ret));
|
||||||
|
LOG_USER_WARN(OB_ERR_DBMS_STATS_PL, "failed to update opt stat task stat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gather_stat != NULL) {
|
||||||
|
if (OB_FAIL(ObOptStatManager::get_instance().update_opt_stat_gather_stat(*gather_stat))) {
|
||||||
|
LOG_WARN("failed to update opt stat gather stat", K(ret));
|
||||||
|
LOG_USER_WARN(OB_ERR_DBMS_STATS_PL, "failed to update opt stat gather stat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
THIS_WORKER.set_session(origin_session);
|
||||||
|
THIS_WORKER.set_timeout_ts(origin_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,6 +527,9 @@ public:
|
|||||||
static int update_system_stats_cache(const uint64_t rpc_tenant_id,
|
static int update_system_stats_cache(const uint64_t rpc_tenant_id,
|
||||||
const uint64_t tenant_id);
|
const uint64_t tenant_id);
|
||||||
|
|
||||||
|
static void update_optimizer_gather_stat_info(const ObOptStatTaskInfo *task_info,
|
||||||
|
const ObOptStatGatherStat *gather_stat);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int check_statistic_table_writeable(sql::ObExecContext &ctx);
|
static int check_statistic_table_writeable(sql::ObExecContext &ctx);
|
||||||
|
|
||||||
|
@ -813,7 +813,7 @@ int ObDbmsStatsUtils::truncate_string_for_opt_stats(const ObObj *old_obj,
|
|||||||
} else if (OB_FAIL(sql::ObTextStringHelper::str_to_lob_storage_obj(alloc, str, *tmp_obj))) {
|
} else if (OB_FAIL(sql::ObTextStringHelper::str_to_lob_storage_obj(alloc, str, *tmp_obj))) {
|
||||||
LOG_WARN("failed to convert str to lob", K(ret));
|
LOG_WARN("failed to convert str to lob", K(ret));
|
||||||
} else {
|
} else {
|
||||||
tmp_obj->set_type(old_obj->get_type());
|
tmp_obj->set_meta_type(old_obj->get_meta());
|
||||||
new_obj = tmp_obj;
|
new_obj = tmp_obj;
|
||||||
is_truncated = true;
|
is_truncated = true;
|
||||||
}
|
}
|
||||||
@ -854,7 +854,7 @@ int ObDbmsStatsUtils::truncate_string_for_opt_stats(ObObj &obj, ObIAllocator &al
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (ObColumnStatParam::is_valid_opt_col_type(obj.get_type()) && obj.is_string_type()) {
|
if (ObColumnStatParam::is_valid_opt_col_type(obj.get_type()) && obj.is_string_type()) {
|
||||||
if(obj.is_lob_storage()) {
|
if(obj.is_lob_storage()) {
|
||||||
ObObjType ori_type = obj.get_type();
|
ObObjMeta ori_meta = obj.get_meta();
|
||||||
ObString str = obj.get_string();
|
ObString str = obj.get_string();
|
||||||
bool can_reuse = false;
|
bool can_reuse = false;
|
||||||
if (OB_FAIL(check_text_can_reuse(obj, can_reuse))) {
|
if (OB_FAIL(check_text_can_reuse(obj, can_reuse))) {
|
||||||
@ -866,7 +866,7 @@ int ObDbmsStatsUtils::truncate_string_for_opt_stats(ObObj &obj, ObIAllocator &al
|
|||||||
} else if (OB_FAIL(sql::ObTextStringHelper::str_to_lob_storage_obj(allocator, str, obj))) {
|
} else if (OB_FAIL(sql::ObTextStringHelper::str_to_lob_storage_obj(allocator, str, obj))) {
|
||||||
LOG_WARN("failed to convert str to lob", K(ret));
|
LOG_WARN("failed to convert str to lob", K(ret));
|
||||||
} else {
|
} else {
|
||||||
obj.set_type(ori_type);
|
obj.set_meta_type(ori_meta);
|
||||||
LOG_TRACE("Succeed to truncate text obj for opt stats", K(ret), K(obj), K(str));
|
LOG_TRACE("Succeed to truncate text obj for opt stats", K(ret), K(obj), K(str));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,20 +107,14 @@ int ObAnalyzeExecutor::execute(ObExecContext &ctx, ObAnalyzeStmt &stmt)
|
|||||||
LOG_TRACE("succeed to gather table stats", K(param));
|
LOG_TRACE("succeed to gather table stats", K(param));
|
||||||
}
|
}
|
||||||
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), param.allocator_->used());
|
running_monitor.set_monitor_result(ret, ObTimeUtility::current_time(), param.allocator_->used());
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
pl::ObDbmsStats::update_optimizer_gather_stat_info(NULL, &gather_stat);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_gather_stat(gather_stat);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
ObOptStatGatherStatList::instance().remove(gather_stat);
|
ObOptStatGatherStatList::instance().remove(gather_stat);
|
||||||
task_info.completed_table_count_ ++;
|
task_info.completed_table_count_ ++;
|
||||||
}
|
}
|
||||||
task_info.task_end_time_ = ObTimeUtility::current_time();
|
task_info.task_end_time_ = ObTimeUtility::current_time();
|
||||||
task_info.ret_code_ = ret;
|
task_info.ret_code_ = ret;
|
||||||
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : params.count() - i + 1;
|
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : params.count() - i + 1;
|
||||||
sql::ObSQLSessionInfo *origin_session = THIS_WORKER.get_session();
|
pl::ObDbmsStats::update_optimizer_gather_stat_info(&task_info, NULL);
|
||||||
THIS_WORKER.set_session(NULL);
|
|
||||||
ObOptStatManager::get_instance().update_opt_stat_task_stat(task_info);
|
|
||||||
THIS_WORKER.set_session(origin_session);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user