diff --git a/src/rootserver/parallel_ddl/ob_create_table_helper.cpp b/src/rootserver/parallel_ddl/ob_create_table_helper.cpp index 2906643c2d..564df7010c 100644 --- a/src/rootserver/parallel_ddl/ob_create_table_helper.cpp +++ b/src/rootserver/parallel_ddl/ob_create_table_helper.cpp @@ -164,6 +164,7 @@ int ObCreateTableHelper::execute() const ObTableSchema &table = arg_.schema_; //create table xx if not exist (...) if (arg_.if_not_exist_) { + res_.do_nothing_ = true; ret = OB_SUCCESS; LOG_INFO("table is exist, no need to create again", "tenant_id", table.get_tenant_id(), diff --git a/src/share/schema/ob_schema_utils.cpp b/src/share/schema/ob_schema_utils.cpp index 81abf0efa2..8885c4fd47 100644 --- a/src/share/schema/ob_schema_utils.cpp +++ b/src/share/schema/ob_schema_utils.cpp @@ -509,7 +509,8 @@ int ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( const ObTimeoutCtx &ctx, sql::ObSQLSessionInfo *session, const uint64_t tenant_id, - const int64_t schema_version) + const int64_t schema_version, + const bool skip_consensus) { int ret = OB_SUCCESS; int64_t start_time = ObTimeUtility::current_time(); @@ -547,7 +548,8 @@ int ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( && consensus_schema_version >= schema_version) { break; } else if (refreshed_schema_version >= schema_version - && ObTimeUtility::current_time() - start_time >= consensus_timeout) { + && (skip_consensus + || ObTimeUtility::current_time() - start_time >= consensus_timeout)) { break; } else { if (REACH_TIME_INTERVAL(1000 * 1000L)) { // 1s diff --git a/src/share/schema/ob_schema_utils.h b/src/share/schema/ob_schema_utils.h index 9a7a4933d3..3cd74ca1cc 100644 --- a/src/share/schema/ob_schema_utils.h +++ b/src/share/schema/ob_schema_utils.h @@ -186,7 +186,8 @@ public: const ObTimeoutCtx &ctx, sql::ObSQLSessionInfo *session, const uint64_t tenant_id, - const int64_t schema_version); + const int64_t schema_version, + const bool skip_consensus); private: static int get_tenant_variable(schema::ObSchemaGetterGuard &schema_guard, uint64_t tenant_id, diff --git a/src/sql/engine/cmd/ob_table_executor.cpp b/src/sql/engine/cmd/ob_table_executor.cpp index 9bd7387a95..535ee5357b 100644 --- a/src/sql/engine/cmd/ob_table_executor.cpp +++ b/src/sql/engine/cmd/ob_table_executor.cpp @@ -607,7 +607,7 @@ int ObCreateTableExecutor::execute(ObExecContext &ctx, ObCreateTableStmt &stmt) } else { int64_t refresh_time = ObTimeUtility::current_time(); if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( - ctx, my_session, tenant_id, res.schema_version_))) { + ctx, my_session, tenant_id, res.schema_version_, res.do_nothing_ /*skip_consensus*/))) { LOG_WARN("fail to check paralleld ddl schema in sync", KR(ret), K(res)); } int64_t end_time = ObTimeUtility::current_time(); @@ -2119,7 +2119,7 @@ int ObTruncateTableExecutor::execute(ObExecContext &ctx, ObTruncateTableStmt &st ret = OB_ERR_UNEXPECTED; LOG_WARN("truncate invalid ddl_res", KR(ret), K(res)); } else if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( - ctx, my_session, tenant_id, res.task_id_))) { + ctx, my_session, tenant_id, res.task_id_, false /*skip_consensus*/))) { LOG_WARN("fail to check parallel ddl schema in sync", KR(ret), K(res)); } int64_t end_time = ObTimeUtility::current_time();