fix create index costs too much time due to query latest execution id failed.
This commit is contained in:
		@ -193,7 +193,6 @@ 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));
 | 
			
		||||
@ -202,10 +201,8 @@ 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 (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 (execution_id < execution_id_) {
 | 
			
		||||
    LOG_INFO("receive a mismatch execution result, ignore", K(ret_code), 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));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -590,30 +590,6 @@ int ObDDLTask::batch_release_snapshot(
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObDDLTask::check_is_latest_execution_id(const int64_t execution_id, bool &is_latest)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  is_latest = true;
 | 
			
		||||
  ObMySQLTransaction trans;
 | 
			
		||||
  ObRootService *root_service = nullptr;
 | 
			
		||||
  int64_t table_task_status = 0;
 | 
			
		||||
  int64_t table_execution_id = 0;
 | 
			
		||||
  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_, table_task_status, table_execution_id))) {
 | 
			
		||||
      LOG_WARN("select for update failed", K(ret), K(task_id_));
 | 
			
		||||
    } else if (table_execution_id > execution_id) {
 | 
			
		||||
      is_latest = false;
 | 
			
		||||
    }
 | 
			
		||||
    trans.end(false);// abort
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObDDLTask::push_execution_id()
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
 | 
			
		||||
@ -338,7 +338,6 @@ public:
 | 
			
		||||
      K_(task_version), K_(parallelism), K_(ddl_stmt_str), K_(compat_mode),
 | 
			
		||||
      K_(sys_task_id), K_(err_code_occurence_cnt), K_(next_schedule_ts), K_(delay_schedule_time), K(execution_id_), K(sql_exec_addr_));
 | 
			
		||||
protected:
 | 
			
		||||
  int check_is_latest_execution_id(const int64_t execution_id, bool &is_latest);
 | 
			
		||||
  virtual bool is_error_need_retry(const int ret_code)
 | 
			
		||||
  {
 | 
			
		||||
    return !share::ObIDDLTask::in_ddl_retry_black_list(ret_code) && (share::ObIDDLTask::in_ddl_retry_white_list(ret_code)
 | 
			
		||||
 | 
			
		||||
@ -958,7 +958,6 @@ int ObIndexBuildTask::update_complete_sstable_job_status(
 | 
			
		||||
    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("not init", K(ret));
 | 
			
		||||
@ -971,10 +970,8 @@ int ObIndexBuildTask::update_complete_sstable_job_status(
 | 
			
		||||
  } 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 (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 (execution_id < execution_id_) {
 | 
			
		||||
    LOG_INFO("receive a mismatch execution result, ignore", K(ret_code), K(execution_id), K(execution_id_));
 | 
			
		||||
  } else {
 | 
			
		||||
    complete_sstable_job_ret_code_ = ret_code;
 | 
			
		||||
    sstable_complete_ts_ = ObTimeUtility::current_time();
 | 
			
		||||
 | 
			
		||||
@ -119,7 +119,6 @@ int ObTableRedefinitionTask::update_complete_sstable_job_status(const common::Ob
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  TCWLockGuard guard(lock_);
 | 
			
		||||
  UNUSED(tablet_id);
 | 
			
		||||
  bool is_latest_execution_id = false;
 | 
			
		||||
  if (OB_UNLIKELY(!is_inited_)) {
 | 
			
		||||
    ret = OB_NOT_INIT;
 | 
			
		||||
    LOG_WARN("ObTableRedefinitionTask has not been inited", K(ret));
 | 
			
		||||
@ -128,10 +127,8 @@ int ObTableRedefinitionTask::update_complete_sstable_job_status(const common::Ob
 | 
			
		||||
  } else if (OB_UNLIKELY(snapshot_version_ != snapshot_version)) {
 | 
			
		||||
    ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
    LOG_WARN("error unexpected, snapshot version is not equal", K(ret), K(snapshot_version_), K(snapshot_version));
 | 
			
		||||
  } 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 (execution_id < execution_id_) {
 | 
			
		||||
    LOG_INFO("receive a mismatch execution result, ignore", K(ret_code), K(execution_id), K(execution_id_));
 | 
			
		||||
  } else {
 | 
			
		||||
    complete_sstable_job_ret_code_ = ret_code;
 | 
			
		||||
    execution_id_ = execution_id; // update ObTableRedefinitionTask::execution_id_ from ObDDLRedefinitionSSTableBuildTask::execution_id_
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user