fix recover table stat failed
This commit is contained in:
@ -1815,14 +1815,14 @@ int ObDDLRedefinitionTask::sync_column_stats_info_accross_tenant(common::ObMySQL
|
|||||||
ObArray<ObObjectID> target_partition_ids;
|
ObArray<ObObjectID> target_partition_ids;
|
||||||
ObHashMap<int64_t, int64_t> part_ids_map;
|
ObHashMap<int64_t, int64_t> part_ids_map;
|
||||||
ObOptStatSqlService &stat_svr = ObOptStatManager::get_instance().get_stat_sql_service();
|
ObOptStatSqlService &stat_svr = ObOptStatManager::get_instance().get_stat_sql_service();
|
||||||
common::ObArenaAllocator allocator(lib::ObLabel("RedefTask"));
|
common::ObArenaAllocator allocator(lib::ObLabel("SyncColStats"));
|
||||||
ObSEArray<ObOptColumnStat *, 4> target_column_stats;
|
ObSEArray<ObOptColumnStat *, 4> target_column_stats;
|
||||||
if (column_stats.empty()) {
|
if (column_stats.empty()) {
|
||||||
LOG_INFO("column stats are empty, no need to sync", K_(tenant_id), K_(dst_tenant_id), K_(object_id), K_(target_object_id));
|
LOG_INFO("column stats are empty, no need to sync", K_(tenant_id), K_(dst_tenant_id), K_(object_id), K_(target_object_id));
|
||||||
} else {
|
} else {
|
||||||
// build partition id mapping table in order to replace the old partition
|
// build partition id mapping table in order to replace the old partition
|
||||||
// with new partition.
|
// with new partition.
|
||||||
if (OB_FAIL(part_ids_map.create(MAP_BUCKET_NUM, "RedefTask"))) {
|
if (OB_FAIL(part_ids_map.create(MAP_BUCKET_NUM, "SyncColStats"))) {
|
||||||
LOG_WARN("failed to create map", K(ret));
|
LOG_WARN("failed to create map", K(ret));
|
||||||
} else if (!data_table_schema.is_partitioned_table()) {
|
} else if (!data_table_schema.is_partitioned_table()) {
|
||||||
if (OB_FAIL(part_ids_map.set_refactored(object_id_, target_object_id_))) {
|
if (OB_FAIL(part_ids_map.set_refactored(object_id_, target_object_id_))) {
|
||||||
@ -1879,6 +1879,7 @@ int ObDDLRedefinitionTask::sync_column_stats_info_accross_tenant(common::ObMySQL
|
|||||||
LOG_INFO("column stats are empty, no need to sync", K_(tenant_id), K_(dst_tenant_id), K_(object_id), K_(target_object_id));
|
LOG_INFO("column stats are empty, no need to sync", K_(tenant_id), K_(dst_tenant_id), K_(object_id), K_(target_object_id));
|
||||||
} else if (OB_FAIL(stat_svr.update_column_stat(dst_tenant_schema_guard,
|
} else if (OB_FAIL(stat_svr.update_column_stat(dst_tenant_schema_guard,
|
||||||
dst_tenant_id_,
|
dst_tenant_id_,
|
||||||
|
allocator,
|
||||||
trans,
|
trans,
|
||||||
target_column_stats,
|
target_column_stats,
|
||||||
ObTimeUtility::current_time(),
|
ObTimeUtility::current_time(),
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public:
|
|||||||
int set_result(const bool is_succeed, const char *buf);
|
int set_result(const bool is_succeed, const char *buf);
|
||||||
int set_result(const int err_code, const share::ObTaskId &trace_id, const ObAddr &addr, const ObString &extra_info = ObString());
|
int set_result(const int err_code, const share::ObTaskId &trace_id, const ObAddr &addr, const ObString &extra_info = ObString());
|
||||||
void reset();
|
void reset();
|
||||||
const char *get_result_str() const { return is_succeed_ ? "SUCCEESS" : "FAILED"; }
|
const char *get_result_str() const { return is_succeed_ ? "SUCCESS" : "FAILED"; }
|
||||||
const char *get_comment() const { return comment_.ptr(); }
|
const char *get_comment() const { return comment_.ptr(); }
|
||||||
bool is_succeed() const { return is_succeed_; }
|
bool is_succeed() const { return is_succeed_; }
|
||||||
bool is_comment_setted() const { return !comment_.is_empty(); }
|
bool is_comment_setted() const { return !comment_.is_empty(); }
|
||||||
|
|||||||
@ -245,12 +245,14 @@ int ObOptStatManager::update_column_stat(share::schema::ObSchemaGetterGuard *sch
|
|||||||
const ObObjPrintParams &print_params)
|
const ObObjPrintParams &print_params)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
ObArenaAllocator allocator("UpdateColStat", OB_MALLOC_NORMAL_BLOCK_SIZE, tenant_id);
|
||||||
int64_t current_time = ObTimeUtility::current_time();
|
int64_t current_time = ObTimeUtility::current_time();
|
||||||
if (!inited_) {
|
if (!inited_) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
LOG_WARN("optimizer statistics manager has not been initialized.", K(ret));
|
LOG_WARN("optimizer statistics manager has not been initialized.", K(ret));
|
||||||
} else if (OB_FAIL(stat_service_.get_sql_service().update_column_stat(schema_guard,
|
} else if (OB_FAIL(stat_service_.get_sql_service().update_column_stat(schema_guard,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
|
allocator,
|
||||||
trans,
|
trans,
|
||||||
column_stats,
|
column_stats,
|
||||||
current_time,
|
current_time,
|
||||||
@ -384,6 +386,7 @@ int ObOptStatManager::batch_write(share::schema::ObSchemaGetterGuard *schema_gua
|
|||||||
const ObObjPrintParams &print_params)
|
const ObObjPrintParams &print_params)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
ObArenaAllocator allocator("UpdateColStat", OB_MALLOC_NORMAL_BLOCK_SIZE, tenant_id);
|
||||||
if (OB_UNLIKELY(!inited_)) {
|
if (OB_UNLIKELY(!inited_)) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
LOG_WARN("optimizer statistics manager has not been initialized.", K(ret));
|
LOG_WARN("optimizer statistics manager has not been initialized.", K(ret));
|
||||||
@ -399,6 +402,7 @@ int ObOptStatManager::batch_write(share::schema::ObSchemaGetterGuard *schema_gua
|
|||||||
} else if (!column_stats.empty() &&
|
} else if (!column_stats.empty() &&
|
||||||
OB_FAIL(stat_service_.get_sql_service().update_column_stat(schema_guard,
|
OB_FAIL(stat_service_.get_sql_service().update_column_stat(schema_guard,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
|
allocator,
|
||||||
trans,
|
trans,
|
||||||
column_stats,
|
column_stats,
|
||||||
current_time,
|
current_time,
|
||||||
|
|||||||
@ -476,6 +476,7 @@ int ObOptStatSqlService::update_table_stat(const uint64_t tenant_id,
|
|||||||
|
|
||||||
int ObOptStatSqlService::update_column_stat(share::schema::ObSchemaGetterGuard *schema_guard,
|
int ObOptStatSqlService::update_column_stat(share::schema::ObSchemaGetterGuard *schema_guard,
|
||||||
const uint64_t exec_tenant_id,
|
const uint64_t exec_tenant_id,
|
||||||
|
ObIAllocator &allocator,
|
||||||
ObMySQLTransaction &trans,
|
ObMySQLTransaction &trans,
|
||||||
const ObIArray<ObOptColumnStat*> &column_stats,
|
const ObIArray<ObOptColumnStat*> &column_stats,
|
||||||
const int64_t current_time,
|
const int64_t current_time,
|
||||||
@ -488,7 +489,6 @@ int ObOptStatSqlService::update_column_stat(share::schema::ObSchemaGetterGuard *
|
|||||||
ObSqlString insert_histogram;
|
ObSqlString insert_histogram;
|
||||||
ObSqlString delete_histogram;
|
ObSqlString delete_histogram;
|
||||||
ObSqlString column_stats_sql;
|
ObSqlString column_stats_sql;
|
||||||
ObArenaAllocator allocator("UpdateColStat", OB_MALLOC_NORMAL_BLOCK_SIZE, exec_tenant_id);
|
|
||||||
bool need_histogram = false;
|
bool need_histogram = false;
|
||||||
if (!inited_) {
|
if (!inited_) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
|
|||||||
@ -105,6 +105,7 @@ public:
|
|||||||
const bool is_history_stat = false);
|
const bool is_history_stat = false);
|
||||||
int update_column_stat(share::schema::ObSchemaGetterGuard *schema_guard,
|
int update_column_stat(share::schema::ObSchemaGetterGuard *schema_guard,
|
||||||
const uint64_t exec_tenant_id,
|
const uint64_t exec_tenant_id,
|
||||||
|
ObIAllocator &allocator,
|
||||||
ObMySQLTransaction &trans,
|
ObMySQLTransaction &trans,
|
||||||
const common::ObIArray<ObOptColumnStat*> &column_stats,
|
const common::ObIArray<ObOptColumnStat*> &column_stats,
|
||||||
const int64_t current_time,
|
const int64_t current_time,
|
||||||
|
|||||||
Reference in New Issue
Block a user