From be2fe9dfceedeaaba31e35093d1ead5eaaaa63e4 Mon Sep 17 00:00:00 2001 From: tino247 Date: Wed, 7 Feb 2024 03:25:45 +0000 Subject: [PATCH] [CP] Fix parallel create conflict problem --- deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h | 1 + src/rootserver/parallel_ddl/ob_create_table_helper.cpp | 6 ++++++ src/share/ob_debug_sync_point.h | 1 + src/sql/engine/cmd/ob_table_executor.cpp | 7 ++++--- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h index f4d6c017ca..d98cad738e 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h @@ -130,6 +130,7 @@ public: void destroy() { init_ = false; } bool is_inited() const { return init_; } void set_timeout(int64_t timeout) { timeout_ = timeout; } + int64_t get_timeout() const { return timeout_; } void set_trace_time(const bool is_trace_time) { is_trace_time_ = is_trace_time; } void set_ratelimit(const bool do_ratelimit) { do_ratelimit_ = do_ratelimit; } void set_bg_flow(const int8_t is_bg_flow) { is_bg_flow_ = is_bg_flow;} diff --git a/src/rootserver/parallel_ddl/ob_create_table_helper.cpp b/src/rootserver/parallel_ddl/ob_create_table_helper.cpp index deafaa24cb..2189de4e85 100644 --- a/src/rootserver/parallel_ddl/ob_create_table_helper.cpp +++ b/src/rootserver/parallel_ddl/ob_create_table_helper.cpp @@ -935,6 +935,12 @@ int ObCreateTableHelper::check_and_set_parent_table_id_() K(parent_database_id), K(parent_table_name)); } } + } else { + if (foreign_key_arg.is_parent_table_mock_) { + ret = OB_ERR_PARALLEL_DDL_CONFLICT; + LOG_WARN("parenet table already exist, should retry", + KR(ret), K_(tenant_id), K(parent_table_id), K(foreign_key_arg)); + } } // parent_table_id will be OB_INVALID_ID in the following cases: // 1. foreign key is self reference. diff --git a/src/share/ob_debug_sync_point.h b/src/share/ob_debug_sync_point.h index 48bc4c252c..aff7666c0e 100755 --- a/src/share/ob_debug_sync_point.h +++ b/src/share/ob_debug_sync_point.h @@ -563,6 +563,7 @@ class ObString; ACT(BEFORE_GET_CONFIG_VERSION_AND_TRANSFER_SCN,)\ ACT(LS_GC_BEFORE_OFFLINE,)\ ACT(BEFORE_FETCH_SIMPLE_TABLES,)\ + ACT(BEFORE_SEND_PARALLEL_CREATE_TABLE,)\ ACT(BEFORE_DROP_TENANT,)\ ACT(MAX_DEBUG_SYNC_POINT,) diff --git a/src/sql/engine/cmd/ob_table_executor.cpp b/src/sql/engine/cmd/ob_table_executor.cpp index 0f429d5943..83ca0a09ff 100644 --- a/src/sql/engine/cmd/ob_table_executor.cpp +++ b/src/sql/engine/cmd/ob_table_executor.cpp @@ -574,10 +574,11 @@ int ObCreateTableExecutor::execute(ObExecContext &ctx, ObCreateTableStmt &stmt) LOG_WARN("rpc proxy create table failed", KR(ret), "dst", common_rpc_proxy->get_server()); } } else { + DEBUG_SYNC(BEFORE_SEND_PARALLEL_CREATE_TABLE); int64_t start_time = ObTimeUtility::current_time(); ObTimeoutCtx ctx; - if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, GCONF._ob_ddl_timeout))) { - LOG_WARN("fail to set timeout ctx", KR(ret)); + if (OB_FAIL(ctx.set_timeout(common_rpc_proxy->get_timeout()))) { + LOG_WARN("fail to set timeout ctx", K(ret)); } else if (OB_FAIL(common_rpc_proxy->parallel_create_table(create_table_arg, res))) { LOG_WARN("rpc proxy create table failed", KR(ret), "dst", common_rpc_proxy->get_server()); } else { @@ -2227,7 +2228,7 @@ int ObTruncateTableExecutor::execute(ObExecContext &ctx, ObTruncateTableStmt &st } else { // new parallel truncate ObTimeoutCtx ctx; - if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, (static_cast(common_rpc_proxy))->timeout()))) { + if (OB_FAIL(ctx.set_timeout(common_rpc_proxy->get_timeout()))) { LOG_WARN("fail to set timeout ctx", K(ret)); } else { int64_t start_time = ObTimeUtility::current_time();