diff --git a/src/rootserver/ddl_task/ob_column_redefinition_task.cpp b/src/rootserver/ddl_task/ob_column_redefinition_task.cpp index 57f1b3dd4..95785ddcf 100644 --- a/src/rootserver/ddl_task/ob_column_redefinition_task.cpp +++ b/src/rootserver/ddl_task/ob_column_redefinition_task.cpp @@ -142,6 +142,10 @@ int ObColumnRedefinitionTask::wait_data_complement(const ObDDLTaskStatus next_ta } else if (ObDDLTaskStatus::REDEFINITION != task_status_) { ret = OB_STATE_NOT_MATCH; LOG_WARN("task status not match", K(ret), K(task_status_)); + } else if (OB_UNLIKELY(snapshot_version_ <= 0)) { + is_build_replica_end = true; // switch to fail. + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected snapshot", K(ret), KPC(this)); } else if (!is_sstable_complete_task_submitted_ && OB_FAIL(send_build_single_replica_request())) { LOG_WARN("fail to send build single replica request", K(ret)); } else if (is_sstable_complete_task_submitted_ && OB_FAIL(check_build_single_replica(is_build_replica_end))) { diff --git a/src/rootserver/ddl_task/ob_constraint_task.cpp b/src/rootserver/ddl_task/ob_constraint_task.cpp index 5df1c55d7..5c14b92c4 100644 --- a/src/rootserver/ddl_task/ob_constraint_task.cpp +++ b/src/rootserver/ddl_task/ob_constraint_task.cpp @@ -711,6 +711,9 @@ int ObConstraintTask::validate_constraint_valid() if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("ObConstraintTask has not been inited", K(ret)); + } else if (OB_UNLIKELY(snapshot_version_ <= 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected snapshot", K(ret), KPC(this)); } else if (OB_FAIL(check_replica_end(is_check_replica_end))) { LOG_WARN("check build replica end", K(ret)); } else { diff --git a/src/rootserver/ddl_task/ob_ddl_task.cpp b/src/rootserver/ddl_task/ob_ddl_task.cpp index bb5749a6d..5a663a9fb 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.cpp +++ b/src/rootserver/ddl_task/ob_ddl_task.cpp @@ -815,13 +815,14 @@ int ObDDLTask::update_task_record_status_and_msg(common::ObISQLClient &proxy, co return ret; } -int ObDDLTask::switch_status(ObDDLTaskStatus new_status, const bool enable_flt, const int ret_code) +int ObDDLTask::switch_status(const ObDDLTaskStatus new_status, const bool enable_flt, const int ret_code) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; bool is_cancel = false; int real_ret_code = ret_code; bool is_tenant_dropped = false; + ObDDLTaskStatus real_new_status = new_status; const ObDDLTaskStatus old_status = task_status_; const bool error_need_retry = OB_SUCCESS != ret_code && is_error_need_retry(ret_code); if (OB_TMP_FAIL(SYS_TASK_STATUS_MGR.is_task_cancel(trace_id_, is_cancel))) { @@ -831,11 +832,11 @@ int ObDDLTask::switch_status(ObDDLTaskStatus new_status, const bool enable_flt, real_ret_code = (OB_SUCCESS == ret_code || error_need_retry) ? OB_CANCELED : ret_code; } else if (SUCCESS == old_status || error_need_retry) { LOG_INFO("error code found, but execute again", K(ret_code), K(ret_code_), K(old_status), K(new_status), K(err_code_occurence_cnt_)); - new_status = old_status; + real_new_status = old_status; real_ret_code = OB_SUCCESS; } ret_code_ = OB_SUCCESS == ret_code_ ? real_ret_code : ret_code_; - ObDDLTaskStatus real_new_status = ret_code_ != OB_SUCCESS ? FAIL : new_status; + real_new_status = OB_SUCCESS != real_ret_code ? FAIL : real_new_status; ObMySQLTransaction trans; ObRootService *root_service = nullptr; if (OB_ISNULL(root_service = GCTX.root_service_)) { @@ -862,7 +863,7 @@ int ObDDLTask::switch_status(ObDDLTaskStatus new_status, const bool enable_flt, ret_code_ = OB_CANCELED; } else if (table_task_status == SUCCESS && old_status != table_task_status) { real_new_status = SUCCESS; - } else if (old_status == new_status) { + } else if (old_status == real_new_status) { // do nothing } else { if (OB_DDL_TASK_ENABLE_TRACING && enable_flt) { @@ -872,7 +873,7 @@ int ObDDLTask::switch_status(ObDDLTaskStatus new_status, const bool enable_flt, } } else if (OB_FAIL(ObDDLTaskRecordOperator::update_task_status( trans, tenant_id_, task_id_, static_cast(real_new_status)))) { - LOG_WARN("update task status failed", K(ret), K(task_id_), K(new_status)); + LOG_WARN("update task status failed", K(ret), K(task_id_), K(real_new_status)); } if (OB_SUCC(ret)) { if (OB_FAIL(ObDDLTaskRecordOperator::update_ret_code(trans, tenant_id_, task_id_, ret_code_))) { diff --git a/src/rootserver/ddl_task/ob_ddl_task.h b/src/rootserver/ddl_task/ob_ddl_task.h index f724befd4..afc78b0e2 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.h +++ b/src/rootserver/ddl_task/ob_ddl_task.h @@ -418,7 +418,7 @@ public: const ObString &get_ddl_stmt_str() const { return ddl_stmt_str_; } int set_ddl_stmt_str(const ObString &ddl_stmt_str); int convert_to_record(ObDDLTaskRecord &task_record, common::ObIAllocator &allocator); - int switch_status(share::ObDDLTaskStatus new_status, const bool enable_flt, const int ret_code); + int switch_status(const share::ObDDLTaskStatus new_status, const bool enable_flt, const int ret_code); int refresh_status(); int refresh_schema_version(); int remove_task_record(); diff --git a/src/rootserver/ddl_task/ob_index_build_task.cpp b/src/rootserver/ddl_task/ob_index_build_task.cpp index e669bcca4..a78c2dca7 100644 --- a/src/rootserver/ddl_task/ob_index_build_task.cpp +++ b/src/rootserver/ddl_task/ob_index_build_task.cpp @@ -841,6 +841,9 @@ int ObIndexBuildTask::wait_data_complement() LOG_WARN("not init", K(ret)); } else if (ObDDLTaskStatus::REDEFINITION != task_status_) { LOG_WARN("task status not match", K(ret), K(task_status_)); + } else if (OB_UNLIKELY(snapshot_version_ <= 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected snapshot", K(ret), KPC(this)); } bool is_request_end = false; diff --git a/src/rootserver/ddl_task/ob_table_redefinition_task.cpp b/src/rootserver/ddl_task/ob_table_redefinition_task.cpp index 055757a99..ab5d8f16b 100644 --- a/src/rootserver/ddl_task/ob_table_redefinition_task.cpp +++ b/src/rootserver/ddl_task/ob_table_redefinition_task.cpp @@ -310,6 +310,10 @@ int ObTableRedefinitionTask::table_redefinition(const ObDDLTaskStatus next_task_ if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("ObTableRedefinitionTask has not been inited", K(ret)); + } else if (OB_UNLIKELY(snapshot_version_ <= 0)) { + is_build_replica_end = true; // switch to fail. + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected snapshot", K(ret), KPC(this)); } if (OB_SUCC(ret) && !is_build_replica_end && 0 == build_replica_request_time_) {