fix truncate table failed caused by delete history stats and enum/set type gather bug
This commit is contained in:
parent
c411be8e33
commit
0995c8b2f5
@ -301,12 +301,6 @@ int ObTableSqlService::drop_inc_partition(common::ObISQLClient &sql_client,
|
||||
"column count", ori_table.get_column_count(), K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat(sql_client, tenant_id, table_id, extra_str))) {
|
||||
LOG_WARN("failed to delete all histogram_stat", K(table_id), K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_table_stat_history(sql_client, tenant_id, table_id, extra_str))) {
|
||||
LOG_WARN("delete from all table stat history failed", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_column_stat_history(sql_client, tenant_id, table_id, extra_str))) {
|
||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id, extra_str))) {
|
||||
LOG_WARN("failed to delete all histogram_stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_monitor_modified(sql_client, tenant_id, table_id, extra_str2))) {
|
||||
LOG_WARN("failed to delete from all monitor modified", K(ret));
|
||||
}
|
||||
@ -405,12 +399,6 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
||||
"column count", ori_table.get_column_count(), K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat(sql_client, tenant_id, table_id, &condition_str))) {
|
||||
LOG_WARN("failed to delete all histogram_stat", K(table_id), K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_table_stat_history(sql_client, tenant_id, table_id, &condition_str))) {
|
||||
LOG_WARN("delete from all table stat history failed", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_column_stat_history(sql_client, tenant_id, table_id, &condition_str))) {
|
||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id, &condition_str))) {
|
||||
LOG_WARN("failed to delete all histogram_stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_monitor_modified(sql_client, tenant_id, table_id, &dml_info_cond_str))) {
|
||||
LOG_WARN("failed to delete from all monitor modified", K(ret));
|
||||
}
|
||||
@ -734,12 +722,6 @@ int ObTableSqlService::drop_table(const ObTableSchema &table_schema,
|
||||
LOG_WARN("failed to delete from all column usage", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_monitor_modified(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete from all monitor modified", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_table_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("delete from all table stat history failed", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_column_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all histogram_stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_optstat_user_prefs(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all optstat user prefs", K(ret));
|
||||
}
|
||||
@ -1973,12 +1955,6 @@ int ObTableSqlService::update_table_options(ObISQLClient &sql_client,
|
||||
LOG_WARN("failed to delete from all column usage", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_monitor_modified(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete from all monitor modified", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_table_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("delete from all table stat history failed", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_column_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_histogram_stat_history(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all histogram stat history", K(ret));
|
||||
} else if (OB_FAIL(delete_from_all_optstat_user_prefs(sql_client, tenant_id, table_id))) {
|
||||
LOG_WARN("failed to delete all optstat user prefs", K(ret));
|
||||
}
|
||||
@ -3350,82 +3326,6 @@ int ObTableSqlService::delete_from_all_column_history(ObISQLClient &sql_client,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSqlService::delete_from_all_table_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDMLSqlSplicer dml;
|
||||
const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id);
|
||||
if (OB_FAIL(dml.add_pk_column("tenant_id", ObSchemaUtils::get_extract_tenant_id(
|
||||
exec_tenant_id, tenant_id)))
|
||||
|| OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id(
|
||||
exec_tenant_id, table_id)))) {
|
||||
LOG_WARN("add column failed", K(ret));
|
||||
} else {
|
||||
int64_t affected_rows = 0;
|
||||
if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) {
|
||||
LOG_WARN("fail to assign extra condition", K(ret));
|
||||
} else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_TABLE_STAT_HISTORY_TNAME,
|
||||
dml, affected_rows))) {
|
||||
LOG_WARN("exec delete failed", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSqlService::delete_from_all_column_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDMLSqlSplicer dml;
|
||||
const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id);
|
||||
if (OB_FAIL(dml.add_pk_column("tenant_id", ObSchemaUtils::get_extract_tenant_id(
|
||||
exec_tenant_id, tenant_id)))
|
||||
|| OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id(
|
||||
exec_tenant_id, table_id)))) {
|
||||
LOG_WARN("add column failed", K(ret));
|
||||
} else {
|
||||
int64_t affected_rows = 0;
|
||||
if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) {
|
||||
LOG_WARN("fail to assign extra condition", K(ret));
|
||||
} else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id, OB_ALL_COLUMN_STAT_HISTORY_TNAME,
|
||||
dml, affected_rows))) {
|
||||
LOG_WARN("exec delete failed", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSqlService::delete_from_all_histogram_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDMLSqlSplicer dml;
|
||||
const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id);
|
||||
if (OB_FAIL(dml.add_pk_column("tenant_id", ObSchemaUtils::get_extract_tenant_id(
|
||||
exec_tenant_id, tenant_id)))
|
||||
|| OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id(
|
||||
exec_tenant_id, table_id)))) {
|
||||
LOG_WARN("add column failed", K(ret));
|
||||
} else {
|
||||
int64_t affected_rows = 0;
|
||||
if (OB_NOT_NULL(extra_condition) && OB_FAIL(dml.get_extra_condition().assign(*extra_condition))) {
|
||||
LOG_WARN("fail to assign extra condition", K(ret));
|
||||
} else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id,
|
||||
OB_ALL_HISTOGRAM_STAT_HISTORY_TNAME,
|
||||
dml, affected_rows))) {
|
||||
LOG_WARN("exec delete failed", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSqlService::delete_from_all_optstat_user_prefs(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id)
|
||||
|
@ -356,18 +356,6 @@ private:
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
const ObSqlString *extra_condition = NULL);
|
||||
int delete_from_all_table_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition = NULL);
|
||||
int delete_from_all_column_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition = NULL);
|
||||
int delete_from_all_histogram_stat_history(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
ObSqlString *extra_condition = NULL);
|
||||
int delete_from_all_optstat_user_prefs(ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id);
|
||||
|
@ -442,17 +442,19 @@ int ObOptColumnStat::merge_obj(const ObObj &obj)
|
||||
num_null_++;
|
||||
} else {
|
||||
num_not_null_++;
|
||||
// max/min
|
||||
if (min_value_.is_null() || obj < min_value_) {
|
||||
inner_min_allocator_.reuse();
|
||||
if (OB_FAIL(ob_write_obj(inner_min_allocator_, obj, min_value_))) {
|
||||
LOG_WARN("fail to deep copy obj", K(ret));
|
||||
if (!obj.get_meta().is_enum_or_set()) {//disable online gather enum/set max/min value. TODO,jiangxiu.wt
|
||||
// max/min
|
||||
if (min_value_.is_null() || obj < min_value_) {
|
||||
inner_min_allocator_.reuse();
|
||||
if (OB_FAIL(ob_write_obj(inner_min_allocator_, obj, min_value_))) {
|
||||
LOG_WARN("fail to deep copy obj", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && (max_value_.is_null() || obj > max_value_)) {
|
||||
inner_max_allocator_.reuse();
|
||||
if (OB_FAIL(ob_write_obj(inner_max_allocator_, obj, max_value_))) {
|
||||
LOG_WARN("fail to deep copy obj", K(ret));
|
||||
if (OB_SUCC(ret) && (max_value_.is_null() || obj > max_value_)) {
|
||||
inner_max_allocator_.reuse();
|
||||
if (OB_FAIL(ob_write_obj(inner_max_allocator_, obj, max_value_))) {
|
||||
LOG_WARN("fail to deep copy obj", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
|
@ -1665,7 +1665,7 @@ int ObOptStatSqlService::get_valid_obj_str(const ObObj &src_obj,
|
||||
if (OB_SUCC(ret) && OB_FAIL(get_obj_str(dst_obj, allocator, dest_str, print_params))) {
|
||||
LOG_WARN("fail to get obj str", K(ret));
|
||||
}
|
||||
LOG_TRACE("succeed to get valid obj str", K(src_obj), K(dst_column_meta), K(dest_str));
|
||||
LOG_TRACE("succeed to get valid obj str", K(src_obj), K(dst_obj));
|
||||
} else if (OB_FAIL(get_obj_str(src_obj, allocator, dest_str, print_params))) {
|
||||
LOG_WARN("failed to get obj str", K(ret), K(src_obj));
|
||||
} else {/*do nothing*/}
|
||||
|
@ -166,7 +166,7 @@ int ObInsertLogPlan::check_need_online_stats_gather(bool &need_osg)
|
||||
LOG_WARN("get unexpected null pointer", K(ret), K(insert_stmt->get_insert_table_info()));
|
||||
} else if (OB_UNLIKELY(ins_table->is_system_table_ || ins_table->is_index_table_)
|
||||
|| insert_stmt->is_insert_up()
|
||||
|| insert_stmt->value_from_select()
|
||||
|| !insert_stmt->value_from_select()
|
||||
|| (!get_optimizer_context().get_session_info()->is_user_session())) {
|
||||
need_gathering = false;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ create user if not exists 'admin' IDENTIFIED BY 'admin';
|
||||
grant all on *.* to 'admin' WITH GRANT OPTION;
|
||||
create database obproxy;
|
||||
|
||||
|
||||
system sleep 5;
|
||||
ANALYZE TABLE OCEANBASE.__ALL_VIRTUAL_CORE_ALL_TABLE COMPUTE STATISTICS;
|
||||
ANALYZE TABLE OCEANBASE.__ALL_VIRTUAL_CORE_COLUMN_TABLE COMPUTE STATISTICS;
|
Loading…
x
Reference in New Issue
Block a user