[CP] fix set partition wise and duplicate table bug

This commit is contained in:
zzg19950727
2024-01-22 13:47:10 +00:00
committed by ob-robot
parent 90aa44cf2d
commit 4555c41209
6 changed files with 29 additions and 33 deletions

View File

@ -850,10 +850,7 @@ int ObLogSet::construct_pq_set_hint(ObPQSetHint &hint)
int ObLogSet::compute_op_parallel_and_server_info() int ObLogSet::compute_op_parallel_and_server_info()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
bool is_partition_wise = DistAlgo::DIST_PARTITION_WISE == get_distributed_algo() if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info())) {
|| DistAlgo::DIST_EXT_PARTITION_WISE == get_distributed_algo()
|| DistAlgo::DIST_SET_PARTITION_WISE == get_distributed_algo();
if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info(is_partition_wise))) {
LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo())); LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo()));
} }
return ret; return ret;

View File

@ -838,8 +838,7 @@ int ObLogSubPlanFilter::rebuild_repart_sharding_info(const ObShardingInfo *input
int ObLogSubPlanFilter::compute_op_parallel_and_server_info() int ObLogSubPlanFilter::compute_op_parallel_and_server_info()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
bool is_partition_wise = DistAlgo::DIST_PARTITION_WISE == get_distributed_algo(); if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info())) {
if (OB_FAIL(compute_normal_multi_child_parallel_and_server_info(is_partition_wise))) {
LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo())); LOG_WARN("failed to compute multi child parallel and server info", K(ret), K(get_distributed_algo()));
} }
return ret; return ret;

View File

@ -709,30 +709,31 @@ int ObLogicalOperator::compute_op_parallel_and_server_info()
} }
int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info(bool is_partition_wise) int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const ObLogicalOperator *max_parallel_child = NULL; const ObLogicalOperator *max_parallel_child = NULL;
bool parallel_is_different = false; bool max_parallel_from_exch = false;
int64_t op_parallel = ObGlobalHint::UNSET_PARALLEL;
int64_t max_available_parallel = ObGlobalHint::DEFAULT_PARALLEL; int64_t max_available_parallel = ObGlobalHint::DEFAULT_PARALLEL;
const ObLogicalOperator *child = NULL; const ObLogicalOperator *child = NULL;
for (int64_t i = 0; OB_SUCC(ret) && i < get_num_of_child(); ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < get_num_of_child(); ++i) {
if (OB_ISNULL(child = get_child(i))) { if (OB_ISNULL(child = get_child(i))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("set operator i-th child is null", K(ret), K(i)); LOG_WARN("set operator i-th child is null", K(ret), K(i));
} else if (child->is_match_all()) { } else if (0 == i) {
max_parallel_child = (NULL == max_parallel_child && (get_num_of_child() - 1) == i)
? child : max_parallel_child;
} else if (ObGlobalHint::UNSET_PARALLEL == op_parallel) {
op_parallel = child->get_parallel();
max_parallel_child = child; max_parallel_child = child;
max_available_parallel = child->get_available_parallel(); max_available_parallel = max_parallel_child->get_available_parallel();
max_parallel_from_exch = LOG_EXCHANGE == max_parallel_child->get_type();
} else if (!max_parallel_from_exch &&
LOG_EXCHANGE == child->get_type()) {
//do nothing
} else { } else {
parallel_is_different |= child->get_parallel() != op_parallel; if (max_parallel_child->get_parallel() < child->get_parallel() ||
max_available_parallel = std::max(max_available_parallel, child->get_available_parallel()); (max_parallel_from_exch && LOG_EXCHANGE != child->get_type())) {
max_parallel_child = max_parallel_child->get_parallel() < child->get_parallel() max_available_parallel = child->get_available_parallel();
? child : max_parallel_child; max_parallel_child = child;
max_parallel_from_exch = LOG_EXCHANGE == max_parallel_child->get_type();
}
} }
} }
@ -740,9 +741,6 @@ int ObLogicalOperator::compute_normal_multi_child_parallel_and_server_info(bool
} else if (OB_ISNULL(max_parallel_child)) { } else if (OB_ISNULL(max_parallel_child)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null ", K(ret), K(max_parallel_child)); LOG_WARN("unexpected null ", K(ret), K(max_parallel_child));
} else if (OB_UNLIKELY(parallel_is_different && !is_partition_wise)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("child op has different parallel except partition wise", K(ret));
} else if (OB_FAIL(get_server_list().assign(max_parallel_child->get_server_list()))) { } else if (OB_FAIL(get_server_list().assign(max_parallel_child->get_server_list()))) {
LOG_WARN("failed to assign server list", K(ret)); LOG_WARN("failed to assign server list", K(ret));
} else { } else {

View File

@ -1324,7 +1324,7 @@ public:
virtual int compute_property(); virtual int compute_property();
int check_property_valid() const; int check_property_valid() const;
int compute_normal_multi_child_parallel_and_server_info(bool is_partition_wise); int compute_normal_multi_child_parallel_and_server_info();
int set_parallel_and_server_info_for_match_all(); int set_parallel_and_server_info_for_match_all();
int get_limit_offset_value(ObRawExpr *percent_expr, int get_limit_offset_value(ObRawExpr *percent_expr,
ObRawExpr *limit_expr, ObRawExpr *limit_expr,

View File

@ -2410,14 +2410,14 @@ int ObSelectLogPlan::check_sharding_inherit_from_access_all(ObLogicalOperator* o
is_inherit_from_access_all = true; is_inherit_from_access_all = true;
} }
} }
if (OB_SUCC(ret) && for (int64_t i = 0; OB_SUCC(ret) && !is_inherit_from_access_all && i < op->get_num_of_child(); ++i) {
!is_inherit_from_access_all && ObLogicalOperator *child = op->get_child(i);
op->get_inherit_sharding_index() != -1) { if (OB_ISNULL(child)) {
int64_t idx = op->get_inherit_sharding_index();
if (idx < 0 || idx >= op->get_num_of_child()) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpect inherit sharding index", K(ret)); LOG_WARN("unexpect null child", K(ret), K(i));
} else if (OB_FAIL(SMART_CALL(check_sharding_inherit_from_access_all(op->get_child(idx), } else if (LOG_EXCHANGE == child->get_type()) {
//do nothing
} else if (OB_FAIL(SMART_CALL(check_sharding_inherit_from_access_all(child,
is_inherit_from_access_all)))) { is_inherit_from_access_all)))) {
LOG_WARN("failed to check sharding inherit from bc2host", K(ret)); LOG_WARN("failed to check sharding inherit from bc2host", K(ret));
} }

View File

@ -1056,9 +1056,9 @@ int ObShardingInfo::is_sharding_equal(const ObShardingInfo *left_sharding,
is_equal = false; is_equal = false;
} else if (left_sharding->get_location_type() != right_sharding->get_location_type()) { } else if (left_sharding->get_location_type() != right_sharding->get_location_type()) {
is_equal = false; is_equal = false;
} else if (left_sharding->is_match_all() || left_sharding->is_local()) { } else if (left_sharding->get_can_reselect_replica() != right_sharding->get_can_reselect_replica()) {
is_equal = true; is_equal = false;
} else if (left_sharding->is_remote()) { } else if (left_sharding->is_remote() || left_sharding->get_can_reselect_replica()) {
ObSEArray<common::ObAddr, 2> left_servers; ObSEArray<common::ObAddr, 2> left_servers;
ObSEArray<common::ObAddr, 2> right_servers; ObSEArray<common::ObAddr, 2> right_servers;
if (OB_FAIL(get_serverlist_from_sharding(*left_sharding, left_servers))) { if (OB_FAIL(get_serverlist_from_sharding(*left_sharding, left_servers))) {
@ -1070,6 +1070,8 @@ int ObShardingInfo::is_sharding_equal(const ObShardingInfo *left_sharding,
is_equal))) { is_equal))) {
LOG_WARN("failed to check equal server list", K(ret)); LOG_WARN("failed to check equal server list", K(ret));
} else { /*do nothing*/ } } else { /*do nothing*/ }
} else if (left_sharding->is_match_all() || left_sharding->is_local()) {
is_equal = true;
} else if (!ObOptimizerUtil::same_exprs(left_sharding->get_partition_keys(), } else if (!ObOptimizerUtil::same_exprs(left_sharding->get_partition_keys(),
right_sharding->get_partition_keys(), right_sharding->get_partition_keys(),
equal_sets) || equal_sets) ||