Fix ddl error code missing
This commit is contained in:
parent
9e17e2b593
commit
f25f7c3958
@ -715,13 +715,14 @@ int ObDDLRetryTask::update_task_status_wait_child_task_finish(
|
||||
ObSqlString sql_string;
|
||||
int64_t curr_task_status = 0;
|
||||
int64_t execution_id = -1; /*unused*/
|
||||
int64_t ret_code = 0;
|
||||
const int64_t new_task_status = ObDDLTaskStatus::WAIT_CHILD_TASK_FINISH;
|
||||
if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || task_id <= 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(tenant_id), K(task_id));
|
||||
} else if (OB_FAIL(DDL_SIM(tenant_id, task_id, RETRY_TASK_UPDATE_BY_CHILD_FAILED))) {
|
||||
LOG_WARN("ddl sim failure", K(ret), K(tenant_id), K(task_id));
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, tenant_id, task_id, curr_task_status, execution_id))) {
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, tenant_id, task_id, curr_task_status, execution_id, ret_code))) {
|
||||
LOG_WARN("select for update failed", K(ret), K(tenant_id), K(task_id));
|
||||
} else if (OB_UNLIKELY(ObDDLTaskStatus::DROP_SCHEMA != curr_task_status)) {
|
||||
ret = OB_STATE_NOT_MATCH;
|
||||
|
@ -1291,6 +1291,7 @@ int ObDDLScheduler::modify_redef_task(const ObDDLTaskID &task_id, ObRedefCallbac
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t table_task_status = 0;
|
||||
int64_t table_execution_id = 0;
|
||||
int64_t table_ret_code = OB_SUCCESS;
|
||||
ObMySQLTransaction trans;
|
||||
common::ObArenaAllocator allocator(lib::ObLabel("task_info"));
|
||||
if (OB_UNLIKELY(!task_id.is_valid())) {
|
||||
@ -1304,7 +1305,8 @@ int ObDDLScheduler::modify_redef_task(const ObDDLTaskID &task_id, ObRedefCallbac
|
||||
task_id.tenant_id_,
|
||||
task_id.task_id_,
|
||||
table_task_status,
|
||||
table_execution_id))) {
|
||||
table_execution_id,
|
||||
table_ret_code))) {
|
||||
LOG_WARN("select for update failed", K(ret), K(task_id.tenant_id_), K(task_id.task_id_));
|
||||
} else {
|
||||
bool need_reschedule = false;
|
||||
@ -1942,6 +1944,7 @@ int ObDDLScheduler::recover_task()
|
||||
int64_t tenant_schema_version = 0;
|
||||
int64_t table_task_status = 0;
|
||||
int64_t execution_id = -1;
|
||||
int64_t ret_code = OB_SUCCESS;
|
||||
bool is_recover_table_aux_tenant = false;
|
||||
ObMySQLTransaction trans;
|
||||
if (OB_FAIL(schema_service.get_tenant_schema_version(cur_record.tenant_id_, tenant_schema_version))) {
|
||||
@ -1963,7 +1966,8 @@ int ObDDLScheduler::recover_task()
|
||||
cur_record.tenant_id_,
|
||||
cur_record.task_id_,
|
||||
table_task_status,
|
||||
execution_id))) {
|
||||
execution_id,
|
||||
ret_code))) {
|
||||
LOG_WARN("select for update failed", K(ret), K(cur_record));
|
||||
} else if (OB_FAIL(schedule_ddl_task(cur_record))) {
|
||||
LOG_WARN("failed to schedule ddl task", K(ret), K(cur_record));
|
||||
|
@ -1072,7 +1072,8 @@ int ObDDLTask::switch_status(const ObDDLTaskStatus new_status, const bool enable
|
||||
} else {
|
||||
int64_t table_task_status = 0;
|
||||
int64_t execution_id = -1;
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, dst_tenant_id_, task_id_, table_task_status, execution_id))) {
|
||||
int64_t ret_code = OB_SUCCESS;
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, dst_tenant_id_, task_id_, table_task_status, execution_id, ret_code))) {
|
||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||
need_retry_ = false;
|
||||
}
|
||||
@ -1082,8 +1083,10 @@ int ObDDLTask::switch_status(const ObDDLTaskStatus new_status, const bool enable
|
||||
real_new_status = FAIL;
|
||||
ret_code_ = OB_CANCELED;
|
||||
} else if (old_status != table_task_status) {
|
||||
// refresh status
|
||||
// refresh status and ret_code
|
||||
real_new_status = static_cast<ObDDLTaskStatus>(table_task_status);
|
||||
ret_code_ = ret_code;
|
||||
LOG_INFO("refresh status", K(task_id_), K(real_new_status), K(ret_code_));
|
||||
} else if (old_status == real_new_status) {
|
||||
// do nothing
|
||||
} else {
|
||||
@ -1096,7 +1099,7 @@ int ObDDLTask::switch_status(const ObDDLTaskStatus new_status, const bool enable
|
||||
trans, dst_tenant_id_, task_id_, static_cast<int64_t>(real_new_status)))) {
|
||||
LOG_WARN("update task status failed", K(ret), K(task_id_), K(real_new_status));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_SUCC(ret) && FAIL == real_new_status) {
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::update_ret_code(trans, dst_tenant_id_, task_id_, ret_code_))) {
|
||||
LOG_WARN("failed to update ret code", K(ret));
|
||||
}
|
||||
@ -1416,13 +1419,14 @@ int ObDDLTask::push_execution_id(const uint64_t tenant_id, const int64_t task_id
|
||||
ObRootService *root_service = nullptr;
|
||||
int64_t task_status = 0;
|
||||
int64_t execution_id = 0;
|
||||
int64_t ret_code = OB_SUCCESS;
|
||||
if (OB_ISNULL(root_service = GCTX.root_service_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("error unexpected, root service must not be nullptr", K(ret));
|
||||
} else if (OB_FAIL(trans.start(&root_service->get_sql_proxy(), tenant_id))) {
|
||||
LOG_WARN("start transaction failed", K(ret));
|
||||
} else {
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, tenant_id, task_id, task_status, execution_id))) {
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, tenant_id, task_id, task_status, execution_id, ret_code))) {
|
||||
LOG_WARN("select for update failed", K(ret), K(task_id));
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::update_execution_id(trans, tenant_id, task_id, execution_id + 1))) {
|
||||
LOG_WARN("update task status failed", K(ret));
|
||||
@ -3436,7 +3440,8 @@ int ObDDLTaskRecordOperator::select_for_update(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t task_id,
|
||||
int64_t &task_status,
|
||||
int64_t &execution_id)
|
||||
int64_t &execution_id,
|
||||
int64_t &ret_code)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlString sql_string;
|
||||
@ -3448,7 +3453,7 @@ int ObDDLTaskRecordOperator::select_for_update(
|
||||
} else {
|
||||
SMART_VAR(ObMySQLProxy::MySQLResult, res) {
|
||||
sqlclient::ObMySQLResult *result = NULL;
|
||||
if (OB_FAIL(sql_string.assign_fmt("SELECT status, execution_id FROM %s WHERE task_id = %lu FOR UPDATE",
|
||||
if (OB_FAIL(sql_string.assign_fmt("SELECT status, execution_id, ret_code FROM %s WHERE task_id = %lu FOR UPDATE",
|
||||
OB_ALL_DDL_TASK_STATUS_TNAME, task_id))) {
|
||||
LOG_WARN("assign sql string failed", K(ret), K(task_id), K(tenant_id));
|
||||
} else if (OB_FAIL(DDL_SIM(tenant_id, task_id, TASK_STATUS_OPERATOR_SLOW))) {
|
||||
@ -3469,6 +3474,7 @@ int ObDDLTaskRecordOperator::select_for_update(
|
||||
} else {
|
||||
EXTRACT_INT_FIELD_MYSQL(*result, "status", task_status, int64_t);
|
||||
EXTRACT_INT_FIELD_MYSQL(*result, "execution_id", execution_id, int64_t);
|
||||
EXTRACT_INT_FIELD_MYSQL(*result, "ret_code", ret_code, int64_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,8 @@ public:
|
||||
const uint64_t tenant_id,
|
||||
const int64_t task_id,
|
||||
int64_t &task_status,
|
||||
int64_t &execution_id);
|
||||
int64_t &execution_id,
|
||||
int64_t &ret_code);
|
||||
|
||||
static int get_ddl_task_record(
|
||||
const uint64_t tenant_id,
|
||||
|
@ -1388,6 +1388,7 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
bool state_finished = true;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
bool drop_index_on_failed = true; // TODO@wenqu: index building triggered by truncate partition may need keep the failed index schema
|
||||
bool index_status_is_available = false;
|
||||
if (OB_FAIL(root_service_->get_schema_service().get_tenant_schema_guard(tenant_id_, schema_guard))) {
|
||||
LOG_WARN("get tenant schema failed", K(ret), K(tenant_id_));
|
||||
} else if (OB_FAIL(schema_guard.check_table_exist(tenant_id_, index_table_id_, is_index_exist))) {
|
||||
@ -1410,6 +1411,7 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
int64_t tmp_snapshot_version = 0;
|
||||
if (ObIndexStatus::INDEX_STATUS_AVAILABLE == index_schema->get_index_status()) {
|
||||
LOG_INFO("index take effect but ddl task failed", K(ret), K(ret_code_), K(index_table_id_));
|
||||
index_status_is_available = true;
|
||||
state_finished = true;
|
||||
} else if (ObIndexStatus::INDEX_STATUS_INDEX_ERROR != index_schema->get_index_status()) {
|
||||
state_finished = false;
|
||||
@ -1490,6 +1492,9 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && state_finished) {
|
||||
if (index_status_is_available) {
|
||||
ret_code_ = OB_SUCCESS;
|
||||
}
|
||||
if (OB_FAIL(cleanup())) {
|
||||
LOG_WARN("cleanup failed", K(ret));
|
||||
}
|
||||
@ -1500,6 +1505,7 @@ int ObIndexBuildTask::clean_on_failed()
|
||||
|
||||
int ObIndexBuildTask::succ()
|
||||
{
|
||||
ret_code_ = OB_SUCCESS;
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
@ -1735,4 +1741,4 @@ int ObIndexBuildTask::update_mlog_last_purge_scn()
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -23622,12 +23622,6 @@ int ObDDLService::update_index_status(const obrpc::ObUpdateIndexStatusArg &arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && arg.task_id_ > 0) {
|
||||
if (OB_FAIL(ObDDLTaskRecordOperator::update_ret_code(trans, tenant_id, arg.task_id_, arg.error_code_))) {
|
||||
LOG_WARN("update ret code failed", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (trans.is_started()) {
|
||||
int commit_ret = trans.end(OB_SUCC(ret));
|
||||
if (OB_SUCCESS != commit_ret) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user