persist execution id and protect ddl start using execution id

This commit is contained in:
YoungYang0820
2022-11-17 06:35:42 +00:00
committed by wangzelin.wzl
parent 798d3f50d6
commit 6fc4bc4a26
24 changed files with 377 additions and 141 deletions

View File

@ -96,6 +96,7 @@ int ObColumnRedefinitionTask::init(const ObDDLTaskRecord &task_record)
schema_version_ = schema_version;
task_status_ = static_cast<ObDDLTaskStatus>(task_record.task_status_);
snapshot_version_ = task_record.snapshot_version_;
execution_id_ = task_record.execution_id_;
tenant_id_ = task_record.tenant_id_;
ret_code_ = task_record.ret_code_;
is_inited_ = true;
@ -140,7 +141,6 @@ int ObColumnRedefinitionTask::send_build_single_replica_request()
ret = OB_NOT_INIT;
LOG_WARN("ObColumnRedefinitionTask has not been inited", K(ret));
} else {
redefinition_execution_id_ = ObTimeUtility::fast_current_time();
ObDDLSingleReplicaExecutorParam param;
param.tenant_id_ = tenant_id_;
param.type_ = task_type_;
@ -150,7 +150,7 @@ int ObColumnRedefinitionTask::send_build_single_replica_request()
param.snapshot_version_ = snapshot_version_;
param.task_id_ = task_id_;
param.parallelism_ = alter_table_arg_.parallelism_;
param.execution_id_ = redefinition_execution_id_;
param.execution_id_ = execution_id_;
if (OB_FAIL(ObDDLUtil::get_tablets(tenant_id_, object_id_, param.source_tablet_ids_))) {
LOG_WARN("fail to get tablets", K(ret), K(tenant_id_), K(object_id_));
} else if (OB_FAIL(ObDDLUtil::get_tablets(tenant_id_, target_object_id_, param.dest_tablet_ids_))) {
@ -192,6 +192,7 @@ int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::O
const int ret_code)
{
int ret = OB_SUCCESS;
bool is_latest_execution_id = false;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("ObColumnRedefinitionTask has not been inited", K(ret));
@ -200,8 +201,10 @@ int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::O
} else if (snapshot_version != snapshot_version_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("snapshot version not match", K(ret), K(snapshot_version), K(snapshot_version_));
} else if (execution_id != redefinition_execution_id_) {
LOG_INFO("receive a mismatch execution result, ignore", K(execution_id), K(redefinition_execution_id_));
} else if (OB_FAIL(check_is_latest_execution_id(execution_id, is_latest_execution_id))) {
LOG_WARN("failed to check latest execution id", K(ret), K(execution_id));
} else if (!is_latest_execution_id) {
LOG_INFO("receive a mismatch execution result, ignore", K(execution_id), K(execution_id_));
} else if (OB_FAIL(replica_builder_.set_partition_task_status(tablet_id, ret_code))) {
LOG_WARN("fail to set partition task status", K(ret));
}