From 6bbf0c65f01e4d2235a4206d85d88051682d50d5 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 6 Apr 2023 14:18:20 +0000 Subject: [PATCH] ddl exist if server is killed. --- src/sql/engine/cmd/ob_ddl_executor_util.cpp | 27 ++++++++++++++++++--- src/sql/engine/cmd/ob_ddl_executor_util.h | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/sql/engine/cmd/ob_ddl_executor_util.cpp b/src/sql/engine/cmd/ob_ddl_executor_util.cpp index 5880b94df4..1e032518d8 100644 --- a/src/sql/engine/cmd/ob_ddl_executor_util.cpp +++ b/src/sql/engine/cmd/ob_ddl_executor_util.cpp @@ -88,7 +88,7 @@ int ObDDLExecutorUtil::wait_ddl_finish( LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id)); } else if (is_tenant_standby) { 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)); } @@ -101,6 +101,13 @@ int ObDDLExecutorUtil::wait_ddl_finish( } else { 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 { 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)); } else if (is_tenant_standby) { 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)); } + + 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; } @@ -226,7 +240,7 @@ int ObDDLExecutorUtil::wait_ddl_retry_task_finish( LOG_WARN("check is standby tenant failed", K(tmp_ret), K(tenant_id)); } else if (is_tenant_standby) { 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)); break; } @@ -239,6 +253,13 @@ int ObDDLExecutorUtil::wait_ddl_retry_task_finish( } else { 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 { ob_usleep(retry_interval); } diff --git a/src/sql/engine/cmd/ob_ddl_executor_util.h b/src/sql/engine/cmd/ob_ddl_executor_util.h index 0bf64c78b2..5d390829aa 100644 --- a/src/sql/engine/cmd/ob_ddl_executor_util.h +++ b/src/sql/engine/cmd/ob_ddl_executor_util.h @@ -13,6 +13,7 @@ #ifndef OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_ #define OCEANBASE_SQL_OB_DDL_EXECUTOR_UTIL_ #include "lib/utility/ob_tracepoint.h" +#include "observer/ob_server.h" #include "share/ob_common_rpc_proxy.h" #include "share/ob_ddl_error_message_table_operator.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 handle_session_exception(ObSQLSessionInfo &session); 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); private: DISALLOW_COPY_AND_ASSIGN(ObDDLExecutorUtil);