From fbce1c596520a2b51e80d950f94e7862af1a8504 Mon Sep 17 00:00:00 2001 From: yishenglanlingzui <395329313@qq.com> Date: Fri, 28 Jul 2023 03:18:10 +0000 Subject: [PATCH] fix bug select for update ... skip locked can't execute parallen --- src/sql/optimizer/ob_log_for_update.cpp | 4 ++-- src/sql/optimizer/ob_log_plan.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sql/optimizer/ob_log_for_update.cpp b/src/sql/optimizer/ob_log_for_update.cpp index e8726a8814..b4d20c8057 100644 --- a/src/sql/optimizer/ob_log_for_update.cpp +++ b/src/sql/optimizer/ob_log_for_update.cpp @@ -89,7 +89,7 @@ int ObLogForUpdate::compute_sharding_info() } else if (OB_ISNULL(get_sharding())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); - } else { + } else { is_partition_wise_ = !is_multi_part_dml_ && !child->is_exchange_allocated() && get_sharding()->is_distributed() && NULL != get_sharding()->get_phy_table_location_info(); @@ -109,7 +109,7 @@ int ObLogForUpdate::allocate_granule_post(AllocGIContext &ctx) if (OB_ISNULL(get_plan())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); - } else if (OB_FAIL(pw_allocate_granule_post(ctx))){ // 分配完GI以后,会对ctx的状态进行清理 + } else if (OB_FAIL(pw_allocate_granule_post(ctx))) { // 分配完GI以后,会对ctx的状态进行清理 LOG_WARN("failed to allocate pw gi post", K(ret)); } else { if (is_partition_wise_state && ctx.is_op_set_pw(this)) { diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index dc4bf2e112..0441a30238 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -12841,9 +12841,14 @@ int ObLogPlan::create_for_update_plan(ObLogicalOperator *&top, int ret = OB_SUCCESS; bool is_multi_part_dml = false; bool is_result_local = false; + ObExchangeInfo exch_info; if (OB_ISNULL(top) || OB_ISNULL(get_stmt())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); + } else if (skip_locked && + top->is_distributed() && + OB_FAIL(allocate_exchange_as_top(top, exch_info))) { + LOG_WARN("fail to allocate exchange op", K(ret), K(skip_locked)); } else if (OB_FAIL(check_need_multi_partition_dml(*get_stmt(), *top, index_dml_infos,