ddl exist if server is killed.

This commit is contained in:
obdev
2023-04-06 14:18:20 +00:00
committed by ob-robot
parent f27a1340ac
commit 6bbf0c65f0
2 changed files with 26 additions and 3 deletions

View File

@ -88,7 +88,7 @@ int ObDDLExecutorUtil::wait_ddl_finish(
LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id)); LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id));
} else if (is_tenant_standby) { } else if (is_tenant_standby) {
ret = OB_STANDBY_READ_ONLY; ret = OB_STANDBY_READ_ONLY;
FORWARD_USER_ERROR(ret, "DDL not finish, need check"); FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id)); LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id));
} }
@ -101,6 +101,13 @@ int ObDDLExecutorUtil::wait_ddl_finish(
} else { } else {
break; break;
} }
}
if (OB_FAIL(ret)) {
} else if (is_server_stopped()) {
ret = OB_TIMEOUT;
FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("server is stopping, check whether the ddl task finish successfully or not", K(ret), K(tenant_id), K(task_id));
} else { } else {
ob_usleep(retry_interval); ob_usleep(retry_interval);
} }
@ -147,9 +154,16 @@ int ObDDLExecutorUtil::wait_build_index_finish(const uint64_t tenant_id, const i
LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id)); LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id));
} else if (is_tenant_standby) { } else if (is_tenant_standby) {
ret = OB_STANDBY_READ_ONLY; ret = OB_STANDBY_READ_ONLY;
FORWARD_USER_ERROR(ret, "DDL not finish, need check"); FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id)); LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id));
} }
if (OB_FAIL(ret)) {
} else if (is_server_stopped()) {
ret = OB_TIMEOUT;
FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("server is stopping, check whether the ddl task finish successfully or not", K(ret), K(tenant_id), K(task_id));
}
} }
return ret; return ret;
} }
@ -226,7 +240,7 @@ int ObDDLExecutorUtil::wait_ddl_retry_task_finish(
LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id)); LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id));
} else if (is_tenant_standby) { } else if (is_tenant_standby) {
ret = OB_STANDBY_READ_ONLY; ret = OB_STANDBY_READ_ONLY;
FORWARD_USER_ERROR(ret, "DDL not finish, need check"); FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id)); LOG_WARN("tenant is standby now, stop wait", K(ret), K(tenant_id));
break; break;
} }
@ -239,6 +253,13 @@ int ObDDLExecutorUtil::wait_ddl_retry_task_finish(
} else { } else {
break; break;
} }
}
if (OB_FAIL(ret)) {
} else if (is_server_stopped()) {
ret = OB_TIMEOUT;
FORWARD_USER_ERROR(ret, "DDL execution status is undecided, please check later if it finishes successfully or not.");
LOG_WARN("server is stopping, check whether the ddl task finish successfully or not", K(ret), K(tenant_id), K(task_id));
} else { } else {
ob_usleep(retry_interval); ob_usleep(retry_interval);
} }

View File

@ -13,6 +13,7 @@
#ifndef OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_ #ifndef OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_
#define OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_ #define OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_
#include "lib/utility/ob_tracepoint.h" #include "lib/utility/ob_tracepoint.h"
#include "observer/ob_server.h"
#include "share/ob_common_rpc_proxy.h" #include "share/ob_common_rpc_proxy.h"
#include "share/ob_ddl_error_message_table_operator.h" #include "share/ob_ddl_error_message_table_operator.h"
#include "sql/session/ob_sql_session_info.h" #include "sql/session/ob_sql_session_info.h"
@ -66,6 +67,7 @@ public:
static int wait_build_index_finish(const uint64_t tenant_id, const int64_t task_id, bool &is_finish); static int wait_build_index_finish(const uint64_t tenant_id, const int64_t task_id, bool &is_finish);
static int handle_session_exception(ObSQLSessionInfo &session); static int handle_session_exception(ObSQLSessionInfo &session);
private: private:
static inline bool is_server_stopped() { return observer::ObServer::get_instance().is_stopped(); }
static int cancel_ddl_task(const int64_t tenant_id, obrpc::ObCommonRpcProxy *common_rpc_proxy); static int cancel_ddl_task(const int64_t tenant_id, obrpc::ObCommonRpcProxy *common_rpc_proxy);
private: private:
DISALLOW_COPY_AND_ASSIGN(ObDDLExecutorUtil); DISALLOW_COPY_AND_ASSIGN(ObDDLExecutorUtil);