fix ddl child tasks recover failed.
This commit is contained in:
@ -355,19 +355,18 @@ int ObColumnRedefinitionTask::copy_table_indexes()
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && need_rebuild_index) {
|
||||
TCWLockGuard guard(lock_);
|
||||
const uint64_t task_key = index_ids.at(i);
|
||||
DependTaskStatus status;
|
||||
status.task_id_ = task_record.task_id_; // child task id is used to judge whether child task finish.
|
||||
TCWLockGuard guard(lock_);
|
||||
if (OB_FAIL(dependent_task_result_map_.set_refactored(task_key, status))) {
|
||||
if (OB_HASH_EXIST == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
if (OB_FAIL(dependent_task_result_map_.get_refactored(task_key, status))) {
|
||||
if (OB_HASH_NOT_EXIST != ret) {
|
||||
LOG_WARN("get from dependent task map failed", K(ret));
|
||||
} else if (OB_FAIL(dependent_task_result_map_.set_refactored(task_key, status))) {
|
||||
LOG_WARN("set dependent task map failed", K(ret), K(task_key));
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("add build index task", K(task_record));
|
||||
}
|
||||
LOG_INFO("add build index task", K(ret), K(task_key), K(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -770,7 +770,6 @@ int ObDDLRedefinitionTask::add_constraint_ddl_task(const int64_t constraint_id)
|
||||
alter_table_schema.clear_constraint();
|
||||
alter_table_schema.set_origin_database_name(database_schema->get_database_name_str());
|
||||
alter_table_schema.set_origin_table_name(table_schema->get_table_name_str());
|
||||
int64_t task_id = 0;
|
||||
if (OB_FAIL(alter_table_schema.add_constraint(*constraint))) {
|
||||
LOG_WARN("add constraint failed", K(ret));
|
||||
} else {
|
||||
@ -799,29 +798,19 @@ int ObDDLRedefinitionTask::add_constraint_ddl_task(const int64_t constraint_id)
|
||||
}
|
||||
} else if (OB_FAIL(root_service->get_ddl_task_scheduler().schedule_ddl_task(task_record))) {
|
||||
LOG_WARN("fail to schedule ddl task", K(ret), K(task_record));
|
||||
} else {
|
||||
task_id = task_record.task_id_;
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
TCWLockGuard guard(lock_);
|
||||
DependTaskStatus status;
|
||||
bool need_set_status = false;
|
||||
status.task_id_ = task_id; // child task id, which is used to judge child task finish.
|
||||
status.task_id_ = task_record.task_id_; // child task id, which is used to judge child task finish.
|
||||
if (OB_FAIL(dependent_task_result_map_.get_refactored(constraint_id, status))) {
|
||||
if (OB_HASH_NOT_EXIST != ret) {
|
||||
LOG_WARN("get from dependent task map failed", K(ret));
|
||||
} else {
|
||||
ret = OB_SUCCESS;
|
||||
need_set_status = true;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && need_set_status) {
|
||||
status.task_id_ = task_id; // child task id is used to judge whether child task finish.
|
||||
if (OB_FAIL(dependent_task_result_map_.set_refactored(constraint_id, status))) {
|
||||
} else if (OB_FAIL(dependent_task_result_map_.set_refactored(constraint_id, status))) {
|
||||
LOG_WARN("set dependent task map failed", K(ret), K(constraint_id));
|
||||
} else {
|
||||
LOG_INFO("add constraint task", K(constraint_id));
|
||||
}
|
||||
}
|
||||
LOG_INFO("add constraint task", K(ret), K(constraint_id), K(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -893,7 +882,6 @@ int ObDDLRedefinitionTask::add_fk_ddl_task(const int64_t fk_id)
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
LOG_WARN("cannot find foreign key in table", K(ret), K(fk_id), K(fk_info_array));
|
||||
} else {
|
||||
DependTaskStatus status;
|
||||
fk_arg.foreign_key_name_ = fk_info.foreign_key_name_;
|
||||
fk_arg.enable_flag_ = fk_info.enable_flag_;
|
||||
fk_arg.is_modify_enable_flag_ = fk_info.enable_flag_;
|
||||
@ -920,14 +908,27 @@ int ObDDLRedefinitionTask::add_fk_ddl_task(const int64_t fk_id)
|
||||
if (OB_FAIL(alter_table_arg.foreign_key_arg_list_.push_back(fk_arg))) {
|
||||
LOG_WARN("push back foreign key arg failed", K(ret));
|
||||
} else if (OB_FAIL(root_service->get_ddl_task_scheduler().create_ddl_task(param, *GCTX.sql_proxy_, task_record))) {
|
||||
if (OB_ENTRY_EXIST == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("submit ddl task failed", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(root_service->get_ddl_task_scheduler().schedule_ddl_task(task_record))) {
|
||||
LOG_WARN("fail to schedule ddl task", K(ret), K(task_record));
|
||||
} else if (FALSE_IT(status.task_id_ = task_record.task_id_)) { // child task id is used to judge whether child task finish.
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
TCWLockGuard guard(lock_);
|
||||
DependTaskStatus status;
|
||||
status.task_id_ = task_record.task_id_; // child task id, which is used to judge child task finish.
|
||||
if (OB_FAIL(dependent_task_result_map_.get_refactored(fk_id, status))) {
|
||||
if (OB_HASH_NOT_EXIST != ret) {
|
||||
LOG_WARN("get from dependent task map failed", K(ret));
|
||||
} else if (OB_FAIL(dependent_task_result_map_.set_refactored(fk_id, status))) {
|
||||
LOG_WARN("set dependent task map failed", K(ret));
|
||||
} else {
|
||||
LOG_INFO("add foregin key ddl task", K(fk_arg), K(fk_id));
|
||||
LOG_WARN("set dependent task map failed", K(ret), K(fk_id));
|
||||
}
|
||||
}
|
||||
LOG_INFO("add fk task", K(ret), K(fk_id), K(status));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,6 +219,7 @@ protected:
|
||||
: ret_code_(INT64_MAX), task_id_(0)
|
||||
{}
|
||||
~DependTaskStatus() = default;
|
||||
TO_STRING_KV(K_(task_id), K_(ret_code));
|
||||
public:
|
||||
int64_t ret_code_;
|
||||
int64_t task_id_;
|
||||
|
||||
@ -2946,7 +2946,7 @@ int ObDDLTaskRecordOperator::to_hex_str(const ObString &src, ObSqlString &dst)
|
||||
|
||||
int ObDDLTaskRecordOperator::insert_record(
|
||||
common::ObISQLClient &proxy,
|
||||
const ObDDLTaskRecord &record)
|
||||
ObDDLTaskRecord &record)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!record.is_valid())) {
|
||||
@ -2967,10 +2967,10 @@ int ObDDLTaskRecordOperator::insert_record(
|
||||
SMART_VAR(ObMySQLProxy::MySQLResult, res) {
|
||||
ObSqlString query_string;
|
||||
sqlclient::ObMySQLResult *result = NULL;
|
||||
if (OB_FAIL(query_string.assign_fmt(
|
||||
" SELECT * FROM %s WHERE object_id = %lu and target_object_id = %lu",
|
||||
OB_ALL_DDL_TASK_STATUS_TNAME, record.object_id_, record.target_object_id_))) {
|
||||
LOG_WARN("assign query string failed", K(ret), K(record));
|
||||
if (OB_FAIL(query_string.assign_fmt("SELECT task_id FROM %s "
|
||||
"WHERE tenant_id = %lu and object_id = %lu and target_object_id = %lu",
|
||||
OB_ALL_DDL_TASK_STATUS_TNAME, record.tenant_id_, record.object_id_, record.target_object_id_))) {
|
||||
LOG_WARN("assign sql string failed", K(ret), K(record));
|
||||
} else if (OB_FAIL(proxy.read(res, record.tenant_id_, query_string.ptr()))) {
|
||||
LOG_WARN("read record failed", K(ret), K(query_string));
|
||||
} else if (OB_UNLIKELY(nullptr == (result = res.get_result()))) {
|
||||
@ -2984,6 +2984,8 @@ int ObDDLTaskRecordOperator::insert_record(
|
||||
}
|
||||
} else {
|
||||
// do not insert duplicated record.
|
||||
// When switch RS at copy_table_dependent_objects phase, we rely on the correct task_id to wait child task finish.
|
||||
EXTRACT_INT_FIELD_MYSQL(*result, "task_id", record.task_id_, int64_t);
|
||||
ret = OB_ENTRY_EXIST;
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public:
|
||||
|
||||
static int insert_record(
|
||||
common::ObISQLClient &proxy,
|
||||
const ObDDLTaskRecord &record);
|
||||
ObDDLTaskRecord &record);
|
||||
|
||||
static int to_hex_str(const ObString &src, ObSqlString &dst);
|
||||
|
||||
|
||||
@ -487,19 +487,18 @@ int ObTableRedefinitionTask::copy_table_indexes()
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && need_rebuild_index) {
|
||||
TCWLockGuard guard(lock_);
|
||||
const uint64_t task_key = index_ids.at(i);
|
||||
DependTaskStatus status;
|
||||
status.task_id_ = task_record.task_id_;
|
||||
TCWLockGuard guard(lock_);
|
||||
if (OB_FAIL(dependent_task_result_map_.set_refactored(task_key, status))) {
|
||||
if (OB_HASH_EXIST == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
if (OB_FAIL(dependent_task_result_map_.get_refactored(task_key, status))) {
|
||||
if (OB_HASH_NOT_EXIST != ret) {
|
||||
LOG_WARN("get from dependent task map failed", K(ret));
|
||||
} else if (OB_FAIL(dependent_task_result_map_.set_refactored(task_key, status))) {
|
||||
LOG_WARN("set dependent task map failed", K(ret), K(task_key));
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("add build index task", K(task_key));
|
||||
}
|
||||
LOG_INFO("add build index task", K(ret), K(task_key), K(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user