fix drop index task continually reports 4007 when cancelling it.
This commit is contained in:
parent
5a7d53fa60
commit
e7d1b14fca
@ -210,7 +210,7 @@ int ObDropIndexTask::drop_index_impl()
|
||||
ret = OB_SCHEMA_ERROR;
|
||||
LOG_WARN("index schema is null", K(ret), K(target_object_id_));
|
||||
} else if (OB_FAIL(index_schema->get_index_name(index_name))) {
|
||||
LOG_WARN("get index name failed", K(ret));
|
||||
LOG_WARN("get index name failed", K(ret), K(index_schema->get_table_type()), KPC(index_schema));
|
||||
} else if (OB_FAIL(schema_guard.get_database_schema(tenant_id_, index_schema->get_database_id(), database_schema))) {
|
||||
LOG_WARN("get database schema failed", K(ret), K(index_schema->get_database_id()));
|
||||
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, index_schema->get_data_table_id(), data_table_schema))) {
|
||||
|
@ -1027,7 +1027,7 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
LOG_WARN("generate drop index sql failed", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(drop_index_sql.append_fmt("drop index \"%.*s\" on \"%.*s\"", index_name.length(), index_name.ptr(),
|
||||
if (OB_FAIL(drop_index_sql.append_fmt("drop index %.*s on %.*s", index_name.length(), index_name.ptr(),
|
||||
data_table_schema->get_table_name_str().length(), data_table_schema->get_table_name_str().ptr()))) {
|
||||
LOG_WARN("generate drop index sql failed", K(ret));
|
||||
}
|
||||
@ -1048,6 +1048,7 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
drop_index_arg.is_add_to_scheduler_ = false;
|
||||
drop_index_arg.is_hidden_ = index_schema->is_user_hidden_table();
|
||||
drop_index_arg.is_in_recyclebin_ = index_schema->is_in_recyclebin();
|
||||
drop_index_arg.is_inner_ = true;
|
||||
if (OB_FAIL(root_service_->get_common_rpc_proxy().drop_index(drop_index_arg, drop_index_res))) {
|
||||
LOG_WARN("drop index failed", K(ret));
|
||||
}
|
||||
|
@ -4904,9 +4904,9 @@ int ObDDLService::alter_table_index(const obrpc::ObAlterTableArg &alter_table_ar
|
||||
ret = OB_ERR_CANT_DROP_FIELD_OR_KEY;
|
||||
LOG_WARN("index table schema should not be null", K(*drop_index_arg), K(ret));
|
||||
LOG_USER_ERROR(OB_ERR_CANT_DROP_FIELD_OR_KEY, drop_index_arg->index_name_.length(), drop_index_arg->index_name_.ptr());
|
||||
} else if (index_table_schema->is_unavailable_index()) {
|
||||
} else if (!drop_index_arg->is_inner_ && index_table_schema->is_unavailable_index()) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support to drop a building index", K(ret), KPC(index_table_schema));
|
||||
LOG_WARN("not support to drop a building index", K(ret), K(drop_index_arg->is_inner_), KPC(index_table_schema));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "dropping a building index is");
|
||||
} else if (drop_index_arg->is_add_to_scheduler_) {
|
||||
ObDDLRes ddl_res;
|
||||
|
@ -164,9 +164,9 @@ int ObIndexBuilder::drop_index(const ObDropIndexArg &arg, obrpc::ObDropIndexRes
|
||||
ret = OB_ERR_CANT_DROP_FIELD_OR_KEY;
|
||||
LOG_WARN("index table schema should not be null", K(arg.index_name_), K(ret));
|
||||
LOG_USER_ERROR(OB_ERR_CANT_DROP_FIELD_OR_KEY, arg.index_name_.length(), arg.index_name_.ptr());
|
||||
} else if (index_table_schema->is_unavailable_index()) {
|
||||
} else if (!arg.is_inner_ && index_table_schema->is_unavailable_index()) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support to drop a building index", K(ret), KPC(index_table_schema));
|
||||
LOG_WARN("not support to drop a building index", K(ret), K(arg.is_inner_), KPC(index_table_schema));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "dropping a building index is");
|
||||
} else if (arg.is_add_to_scheduler_) {
|
||||
ObDDLOperator ddl_operator(ddl_service_.get_schema_service(), ddl_service_.get_sql_proxy());
|
||||
|
@ -2176,7 +2176,8 @@ DEF_TO_STRING(ObDropIndexArg) {
|
||||
K_(index_table_id),
|
||||
K_(is_add_to_scheduler),
|
||||
K_(is_in_recyclebin),
|
||||
K_(is_hidden));
|
||||
K_(is_hidden),
|
||||
K_(is_inner));
|
||||
J_OBJ_END();
|
||||
return pos;
|
||||
}
|
||||
@ -2189,7 +2190,8 @@ OB_SERIALIZE_MEMBER((ObDropIndexArg, ObIndexArg),
|
||||
index_table_id_,
|
||||
is_add_to_scheduler_,
|
||||
is_in_recyclebin_,
|
||||
is_hidden_);
|
||||
is_hidden_,
|
||||
is_inner_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObDropIndexRes, tenant_id_, index_table_id_, schema_version_, task_id_);
|
||||
|
||||
|
@ -1274,6 +1274,7 @@ public:
|
||||
is_add_to_scheduler_ = false;
|
||||
is_hidden_ = false;
|
||||
is_in_recyclebin_ = false;
|
||||
is_inner_ = false;
|
||||
}
|
||||
virtual ~ObDropIndexArg() {}
|
||||
void reset()
|
||||
@ -1283,12 +1284,14 @@ public:
|
||||
is_add_to_scheduler_ = false;
|
||||
is_hidden_ = false;
|
||||
is_in_recyclebin_ = false;
|
||||
is_inner_ = false;
|
||||
}
|
||||
bool is_valid() const { return ObIndexArg::is_valid(); }
|
||||
uint64_t index_table_id_;
|
||||
bool is_add_to_scheduler_;
|
||||
bool is_hidden_;
|
||||
bool is_in_recyclebin_;
|
||||
bool is_inner_;
|
||||
|
||||
DECLARE_VIRTUAL_TO_STRING;
|
||||
};
|
||||
|
@ -48,7 +48,8 @@ int ObDDLExecutorUtil::wait_ddl_finish(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t task_id,
|
||||
ObSQLSessionInfo &session,
|
||||
obrpc::ObCommonRpcProxy *common_rpc_proxy)
|
||||
obrpc::ObCommonRpcProxy *common_rpc_proxy,
|
||||
const bool is_support_cancel)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t retry_interval = 100 * 1000;
|
||||
@ -70,8 +71,8 @@ int ObDDLExecutorUtil::wait_ddl_finish(
|
||||
}
|
||||
break;
|
||||
} else if (OB_FAIL(handle_session_exception(session))) {
|
||||
LOG_WARN("session exeception happened", K(ret));
|
||||
if (OB_FAIL(cancel_ddl_task(tenant_id, common_rpc_proxy))) {
|
||||
LOG_WARN("session exeception happened", K(ret), K(is_support_cancel));
|
||||
if (is_support_cancel && OB_FAIL(cancel_ddl_task(tenant_id, common_rpc_proxy))) {
|
||||
LOG_WARN("cancel ddl task failed", K(ret));
|
||||
} else {
|
||||
break;
|
||||
|
@ -55,7 +55,8 @@ public:
|
||||
const uint64_t tenant_id,
|
||||
const int64_t task_id,
|
||||
ObSQLSessionInfo &session,
|
||||
obrpc::ObCommonRpcProxy *common_rpc_proxy);
|
||||
obrpc::ObCommonRpcProxy *common_rpc_proxy,
|
||||
const bool is_support_cancel = true);
|
||||
static int wait_ddl_retry_task_finish(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t task_id,
|
||||
|
@ -685,6 +685,8 @@ int ObAlterTableExecutor::alter_table_rpc_v2(
|
||||
const bool is_sync_ddl_user)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// do not support cancel drop_index_task.
|
||||
bool is_support_cancel = true;
|
||||
const ObSArray<obrpc::ObIndexArg *> index_arg_list = alter_table_arg.index_arg_list_;
|
||||
ObSArray<obrpc::ObIndexArg *> add_index_arg_list;
|
||||
ObSArray<obrpc::ObIndexArg *> drop_index_args;
|
||||
@ -714,6 +716,7 @@ int ObAlterTableExecutor::alter_table_rpc_v2(
|
||||
} else {
|
||||
ObDropIndexArg *drop_index_arg = static_cast<ObDropIndexArg *>(index_arg);
|
||||
drop_index_arg->is_add_to_scheduler_ = true;
|
||||
is_support_cancel = false;
|
||||
}
|
||||
} else { // for rename/drop index action
|
||||
if (OB_FAIL(alter_table_arg.index_arg_list_.push_back(index_arg))) {
|
||||
@ -744,7 +747,7 @@ int ObAlterTableExecutor::alter_table_rpc_v2(
|
||||
ObIArray<obrpc::ObDDLRes> &ddl_ress = res.ddl_res_array_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < ddl_ress.count(); ++i) {
|
||||
ObDDLRes &ddl_res = ddl_ress.at(i);
|
||||
if (OB_FAIL(ObDDLExecutorUtil::wait_ddl_finish(ddl_res.tenant_id_, ddl_res.task_id_, *my_session, common_rpc_proxy))) {
|
||||
if (OB_FAIL(ObDDLExecutorUtil::wait_ddl_finish(ddl_res.tenant_id_, ddl_res.task_id_, *my_session, common_rpc_proxy, is_support_cancel))) {
|
||||
LOG_WARN("wait drop index finish", K(ret));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user