[CP] fix table dml info maintenance bug
This commit is contained in:
@ -193,7 +193,8 @@ int ObTableSqlService::delete_table_part_info(const ObTableSchema &table_schema,
|
|||||||
|
|
||||||
int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc_table,
|
int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc_table,
|
||||||
ObSqlString &sql,
|
ObSqlString &sql,
|
||||||
ObSqlString &condition_str)
|
ObSqlString &condition_str,
|
||||||
|
ObSqlString &dml_info_cond_str)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObPartition **part_array = inc_table.get_part_array();
|
ObPartition **part_array = inc_table.get_part_array();
|
||||||
@ -205,6 +206,8 @@ int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc
|
|||||||
LOG_WARN("assign sql str fail", KR(ret));
|
LOG_WARN("assign sql str fail", KR(ret));
|
||||||
} else if (OB_FAIL(sql.append_fmt(" AND (0 = 1"))) {
|
} else if (OB_FAIL(sql.append_fmt(" AND (0 = 1"))) {
|
||||||
LOG_WARN("append sql str fail", KR(ret));
|
LOG_WARN("append sql str fail", KR(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.append_fmt(" (0 = 1"))) {
|
||||||
|
LOG_WARN("append sql str fail", K(ret));
|
||||||
}
|
}
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < inc_part_num; i++) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < inc_part_num; i++) {
|
||||||
ObPartition *part = part_array[i];
|
ObPartition *part = part_array[i];
|
||||||
@ -216,6 +219,10 @@ int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc
|
|||||||
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu",
|
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu",
|
||||||
part->get_part_id()))) {
|
part->get_part_id()))) {
|
||||||
LOG_WARN("fail to append fmt", KR(ret));
|
LOG_WARN("fail to append fmt", KR(ret));
|
||||||
|
} else if (inc_table.get_part_level() == PARTITION_LEVEL_ONE &&
|
||||||
|
OB_FAIL(dml_info_cond_str.append_fmt(" OR tablet_id = %lu",
|
||||||
|
part->get_tablet_id().id()))) {
|
||||||
|
LOG_WARN("fail to append fmt", K(ret));
|
||||||
} else {
|
} else {
|
||||||
// get subpartition info
|
// get subpartition info
|
||||||
for (int64_t j = 0; OB_SUCC(ret) && j < part->get_subpartition_num(); j++) {
|
for (int64_t j = 0; OB_SUCC(ret) && j < part->get_subpartition_num(); j++) {
|
||||||
@ -226,6 +233,9 @@ int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc
|
|||||||
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu",
|
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu",
|
||||||
subpart->get_sub_part_id()))) {
|
subpart->get_sub_part_id()))) {
|
||||||
LOG_WARN("append_fmt failed", KR(ret));
|
LOG_WARN("append_fmt failed", KR(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.append_fmt(" OR tablet_id = %lu",
|
||||||
|
subpart->get_tablet_id().id()))) {
|
||||||
|
LOG_WARN("fail to append fmt", K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,6 +245,8 @@ int ObTableSqlService::drop_inc_partition_add_extra_str(const ObTableSchema &inc
|
|||||||
LOG_WARN("append_fmt failed", KR(ret));
|
LOG_WARN("append_fmt failed", KR(ret));
|
||||||
} else if (OB_FAIL(sql.append_fmt(" )"))) {
|
} else if (OB_FAIL(sql.append_fmt(" )"))) {
|
||||||
LOG_WARN("append_fmt failed", KR(ret));
|
LOG_WARN("append_fmt failed", KR(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.append_fmt(" )"))) {
|
||||||
|
LOG_WARN("failed to append fmt", K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -259,6 +271,8 @@ int ObTableSqlService::drop_inc_partition(common::ObISQLClient &sql_client,
|
|||||||
ObSqlString sql;
|
ObSqlString sql;
|
||||||
// used to sync partition level info.
|
// used to sync partition level info.
|
||||||
ObSqlString condition_str;
|
ObSqlString condition_str;
|
||||||
|
// used to sync partition dml info.
|
||||||
|
ObSqlString dml_info_cond_str;
|
||||||
const int64_t inc_part_num = inc_table.get_partition_num();
|
const int64_t inc_part_num = inc_table.get_partition_num();
|
||||||
ObPartition **part_array = inc_table.get_part_array();
|
ObPartition **part_array = inc_table.get_part_array();
|
||||||
|
|
||||||
@ -272,13 +286,14 @@ int ObTableSqlService::drop_inc_partition(common::ObISQLClient &sql_client,
|
|||||||
ObSchemaUtils::get_extract_schema_id(exec_tenant_id, table_id)))) {
|
ObSchemaUtils::get_extract_schema_id(exec_tenant_id, table_id)))) {
|
||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
} else if (!is_truncate_table) {
|
} else if (!is_truncate_table) {
|
||||||
if (OB_FAIL(drop_inc_partition_add_extra_str(inc_table, sql, condition_str))) {
|
if (OB_FAIL(drop_inc_partition_add_extra_str(inc_table, sql, condition_str, dml_info_cond_str))) {
|
||||||
LOG_WARN("fail to add extra str when drop inc partition", K(ret), K(inc_table));
|
LOG_WARN("fail to add extra str when drop inc partition", K(ret), K(inc_table));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// delete stat info here.
|
// delete stat info here.
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
ObSqlString *extra_str = condition_str.empty() ? NULL : &condition_str;
|
ObSqlString *extra_str = condition_str.empty() ? NULL : &condition_str;
|
||||||
|
ObSqlString *extra_str2 = dml_info_cond_str.empty() ? NULL : &dml_info_cond_str;
|
||||||
if (OB_FAIL(delete_from_all_table_stat(sql_client, tenant_id, table_id, extra_str))) {
|
if (OB_FAIL(delete_from_all_table_stat(sql_client, tenant_id, table_id, extra_str))) {
|
||||||
LOG_WARN("delete from all table stat failed", K(ret));
|
LOG_WARN("delete from all table stat failed", K(ret));
|
||||||
} else if (OB_FAIL(delete_from_all_column_stat(sql_client, tenant_id, table_id, extra_str))) {
|
} else if (OB_FAIL(delete_from_all_column_stat(sql_client, tenant_id, table_id, extra_str))) {
|
||||||
@ -292,6 +307,8 @@ int ObTableSqlService::drop_inc_partition(common::ObISQLClient &sql_client,
|
|||||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
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))) {
|
} 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));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +341,7 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
|||||||
} else {
|
} else {
|
||||||
ObSqlString sql;
|
ObSqlString sql;
|
||||||
ObSqlString condition_str;
|
ObSqlString condition_str;
|
||||||
|
ObSqlString dml_info_cond_str;
|
||||||
const int64_t inc_part_num = inc_table.get_partition_num();
|
const int64_t inc_part_num = inc_table.get_partition_num();
|
||||||
int64_t inc_subpart_num = 0;
|
int64_t inc_subpart_num = 0;
|
||||||
ObPartition **part_array = inc_table.get_part_array();
|
ObPartition **part_array = inc_table.get_part_array();
|
||||||
@ -339,6 +357,8 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
|||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
} else if (OB_FAIL(condition_str.assign_fmt("( 1 = 0"))) {
|
} else if (OB_FAIL(condition_str.assign_fmt("( 1 = 0"))) {
|
||||||
LOG_WARN("assign fmt failed", K(ret));
|
LOG_WARN("assign fmt failed", K(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.assign_fmt("( 1 = 0"))) {
|
||||||
|
LOG_WARN("assign fmt failed", K(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < inc_part_num; i++) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < inc_part_num; i++) {
|
||||||
@ -361,6 +381,8 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
|||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu", subpart->get_sub_part_id()))) {
|
} else if (OB_FAIL(condition_str.append_fmt(" OR partition_id = %lu", subpart->get_sub_part_id()))) {
|
||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.append_fmt(" OR tablet_id = %lu", subpart->get_tablet_id().id()))) {
|
||||||
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,6 +392,8 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
|||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
} else if (OB_FAIL(condition_str.append_fmt(" )"))) {
|
} else if (OB_FAIL(condition_str.append_fmt(" )"))) {
|
||||||
LOG_WARN("append_fmt failed", K(ret));
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
|
} else if (OB_FAIL(dml_info_cond_str.append_fmt(" )"))) {
|
||||||
|
LOG_WARN("append_fmt failed", K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +411,8 @@ int ObTableSqlService::drop_inc_sub_partition(common::ObISQLClient &sql_client,
|
|||||||
LOG_WARN("failed to delete all column stat history", K(ret));
|
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))) {
|
} 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));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4811,7 +4837,8 @@ int ObTableSqlService::delete_from_all_column_usage(ObISQLClient &sql_client,
|
|||||||
|
|
||||||
int ObTableSqlService::delete_from_all_monitor_modified(ObISQLClient &sql_client,
|
int ObTableSqlService::delete_from_all_monitor_modified(ObISQLClient &sql_client,
|
||||||
const uint64_t tenant_id,
|
const uint64_t tenant_id,
|
||||||
const uint64_t table_id)
|
const uint64_t table_id,
|
||||||
|
const ObSqlString *extra_condition)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObDMLSqlSplicer dml;
|
ObDMLSqlSplicer dml;
|
||||||
@ -4822,6 +4849,9 @@ int ObTableSqlService::delete_from_all_monitor_modified(ObISQLClient &sql_client
|
|||||||
|| OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id(
|
|| OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id(
|
||||||
exec_tenant_id, table_id)))) {
|
exec_tenant_id, table_id)))) {
|
||||||
LOG_WARN("add column failed", K(ret));
|
LOG_WARN("add column failed", K(ret));
|
||||||
|
} else 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,
|
} else if (OB_FAIL(exec_delete(sql_client, tenant_id, table_id,
|
||||||
OB_ALL_MONITOR_MODIFIED_TNAME,
|
OB_ALL_MONITOR_MODIFIED_TNAME,
|
||||||
dml, affected_rows))) {
|
dml, affected_rows))) {
|
||||||
|
|||||||
@ -167,7 +167,8 @@ public:
|
|||||||
const int64_t schema_version);
|
const int64_t schema_version);
|
||||||
int drop_inc_partition_add_extra_str(const ObTableSchema &inc_table,
|
int drop_inc_partition_add_extra_str(const ObTableSchema &inc_table,
|
||||||
ObSqlString &sql,
|
ObSqlString &sql,
|
||||||
ObSqlString &condition_str);
|
ObSqlString &condition_str,
|
||||||
|
ObSqlString &dml_info_cond_str);
|
||||||
int drop_inc_partition(common::ObISQLClient &sql_client,
|
int drop_inc_partition(common::ObISQLClient &sql_client,
|
||||||
const ObTableSchema &ori_table,
|
const ObTableSchema &ori_table,
|
||||||
const ObTableSchema &inc_table,
|
const ObTableSchema &inc_table,
|
||||||
@ -353,7 +354,8 @@ private:
|
|||||||
const uint64_t table_id);
|
const uint64_t table_id);
|
||||||
int delete_from_all_monitor_modified(ObISQLClient &sql_client,
|
int delete_from_all_monitor_modified(ObISQLClient &sql_client,
|
||||||
const uint64_t tenant_id,
|
const uint64_t tenant_id,
|
||||||
const uint64_t table_id);
|
const uint64_t table_id,
|
||||||
|
const ObSqlString *extra_condition = NULL);
|
||||||
int delete_from_all_table_stat_history(ObISQLClient &sql_client,
|
int delete_from_all_table_stat_history(ObISQLClient &sql_client,
|
||||||
const uint64_t tenant_id,
|
const uint64_t tenant_id,
|
||||||
const uint64_t table_id,
|
const uint64_t table_id,
|
||||||
|
|||||||
@ -929,10 +929,17 @@ int ObOptStatMonitorManager::clean_useless_dml_stat_info(uint64_t tenant_id)
|
|||||||
const char* all_table_name = NULL;
|
const char* all_table_name = NULL;
|
||||||
if (OB_FAIL(ObSchemaUtils::get_all_table_name(tenant_id, all_table_name))) {
|
if (OB_FAIL(ObSchemaUtils::get_all_table_name(tenant_id, all_table_name))) {
|
||||||
LOG_WARN("failed to get all table name", K(ret));
|
LOG_WARN("failed to get all table name", K(ret));
|
||||||
} else if (OB_FAIL(delete_sql.append_fmt("delete from %s m where not exists " \
|
} else if (OB_FAIL(delete_sql.append_fmt("DELETE FROM %s m WHERE (NOT EXISTS (SELECT 1 " \
|
||||||
"(select 1 from %s t where t.table_id = m.table_id and t.tenant_id = m.tenant_id) "\
|
"FROM %s t, %s db WHERE t.tenant_id = db.tenant_id AND t.database_id = db.database_id "\
|
||||||
" and table_id > %ld;",
|
"AND t.table_id = m.table_id AND t.tenant_id = m.tenant_id AND db.database_name != '__recyclebin') "\
|
||||||
share::OB_ALL_MONITOR_MODIFIED_TNAME, all_table_name, OB_MAX_INNER_TABLE_ID))) {
|
"OR (tenant_id, table_id, tablet_id) IN (SELECT m.tenant_id, m.table_id, m.tablet_id FROM "\
|
||||||
|
"%s m, %s t WHERE t.table_id = m.table_id AND t.tenant_id = m.tenant_id AND t.part_level > 0 "\
|
||||||
|
"AND NOT EXISTS (SELECT 1 FROM %s p WHERE p.table_id = m.table_id AND p.tenant_id = m.tenant_id AND p.tablet_id = m.tablet_id) "\
|
||||||
|
"AND NOT EXISTS (SELECT 1 FROM %s sp WHERE sp.table_id = m.table_id AND sp.tenant_id = m.tenant_id AND sp.tablet_id = m.tablet_id))) "\
|
||||||
|
"AND table_id > %ld;",
|
||||||
|
share::OB_ALL_MONITOR_MODIFIED_TNAME, all_table_name, share::OB_ALL_DATABASE_TNAME,
|
||||||
|
share::OB_ALL_MONITOR_MODIFIED_TNAME, all_table_name, share::OB_ALL_PART_TNAME,
|
||||||
|
share::OB_ALL_SUB_PART_TNAME, OB_MAX_INNER_TABLE_ID))) {
|
||||||
LOG_WARN("failed to append fmt", K(ret));
|
LOG_WARN("failed to append fmt", K(ret));
|
||||||
} else if (OB_FAIL(mysql_proxy_->write(tenant_id, delete_sql.ptr(), affected_rows))) {
|
} else if (OB_FAIL(mysql_proxy_->write(tenant_id, delete_sql.ptr(), affected_rows))) {
|
||||||
LOG_WARN("failed to execute sql", K(ret), K(delete_sql));
|
LOG_WARN("failed to execute sql", K(ret), K(delete_sql));
|
||||||
|
|||||||
@ -52,8 +52,8 @@ int ObAnalyzeStmtResolver::resolve(const ParseNode &parse_tree)
|
|||||||
LOG_WARN("failed to get force parallel query dop", K(ret));
|
LOG_WARN("failed to get force parallel query dop", K(ret));
|
||||||
} else if (T_ANALYZE == parse_tree.type_) {
|
} else if (T_ANALYZE == parse_tree.type_) {
|
||||||
if (lib::is_mysql_mode() && !session_info_->is_enable_sql_extension()) {
|
if (lib::is_mysql_mode() && !session_info_->is_enable_sql_extension()) {
|
||||||
ret = OB_ERR_PARSER_SYNTAX;
|
ret = OB_NOT_SUPPORTED;
|
||||||
LOG_WARN("The Oracle-mode analyze syntax is not supported under the MySQL mode", K(ret));
|
LOG_USER_ERROR(OB_NOT_SUPPORTED, "The Oracle-mode analyze syntax is used in the disable sql extension MySQL-mode");
|
||||||
} else if (OB_FAIL(resolve_oracle_analyze(parse_tree, *analyze_stmt))) {
|
} else if (OB_FAIL(resolve_oracle_analyze(parse_tree, *analyze_stmt))) {
|
||||||
LOG_WARN("failed to resolve oracle analyze stmt", K(ret));
|
LOG_WARN("failed to resolve oracle analyze stmt", K(ret));
|
||||||
} else { /*do nothing*/ }
|
} else { /*do nothing*/ }
|
||||||
|
|||||||
Reference in New Issue
Block a user