Fix get twice full leader with uncertain dml location

This commit is contained in:
qianchanger
2023-06-02 12:17:36 +00:00
committed by ob-robot
parent 5dbd928a66
commit 9a3c3206f7
2 changed files with 16 additions and 11 deletions

View File

@ -297,6 +297,7 @@ int ObPXServerAddrUtil::alloc_by_data_distribution_inner(
} }
} else { } else {
ObDASTableLoc *table_loc = NULL; ObDASTableLoc *table_loc = NULL;
ObDASTableLoc *dml_full_loc = NULL;
uint64_t table_location_key = OB_INVALID_INDEX; uint64_t table_location_key = OB_INVALID_INDEX;
uint64_t ref_table_id = OB_INVALID_ID; uint64_t ref_table_id = OB_INVALID_ID;
if (scan_ops.count() > 0) { if (scan_ops.count() > 0) {
@ -323,6 +324,9 @@ int ObPXServerAddrUtil::alloc_by_data_distribution_inner(
table_location_key, table_location_key,
ref_table_id, ref_table_id,
table_loc)); table_loc));
if (OB_SUCC(ret)) {
dml_full_loc = table_loc;
}
} else { } else {
if (OB_NOT_NULL(scan_op) && scan_op->is_external_table_) { if (OB_NOT_NULL(scan_op) && scan_op->is_external_table_) {
// create new table loc for a random dfo distribution for external table // create new table loc for a random dfo distribution for external table
@ -348,7 +352,7 @@ int ObPXServerAddrUtil::alloc_by_data_distribution_inner(
LOG_WARN("the location array is empty", K(locations.size()), K(ret)); LOG_WARN("the location array is empty", K(locations.size()), K(ret));
} else if (OB_FAIL(build_dfo_sqc(ctx, locations, dfo))) { } else if (OB_FAIL(build_dfo_sqc(ctx, locations, dfo))) {
LOG_WARN("fail fill dfo with sqc infos", K(dfo), K(ret)); LOG_WARN("fail fill dfo with sqc infos", K(dfo), K(ret));
} else if (OB_FAIL(set_dfo_accessed_location(ctx, table_location_key, dfo, scan_ops, dml_op))) { } else if (OB_FAIL(set_dfo_accessed_location(ctx, table_location_key, dfo, scan_ops, dml_op, dml_full_loc))) {
LOG_WARN("fail to set all table partition for tsc", K(ret)); LOG_WARN("fail to set all table partition for tsc", K(ret));
} else if (OB_NOT_NULL(table_locations) && !table_locations->empty() && } else if (OB_NOT_NULL(table_locations) && !table_locations->empty() &&
OB_FAIL(build_dynamic_partition_table_location(scan_ops, table_locations, dfo))) { OB_FAIL(build_dynamic_partition_table_location(scan_ops, table_locations, dfo))) {
@ -657,7 +661,7 @@ int ObPXServerAddrUtil::alloc_by_temp_child_distribution_inner(ObExecContext &ex
} else if (scan_ops.empty()) { } else if (scan_ops.empty()) {
} else if (FALSE_IT(base_table_location_key = scan_ops.at(0)->get_table_loc_id())) { } else if (FALSE_IT(base_table_location_key = scan_ops.at(0)->get_table_loc_id())) {
} else if (OB_FAIL(set_dfo_accessed_location(exec_ctx, } else if (OB_FAIL(set_dfo_accessed_location(exec_ctx,
base_table_location_key, child, scan_ops, NULL))) { base_table_location_key, child, scan_ops, NULL, NULL))) {
LOG_WARN("fail to set all table partition for tsc", K(ret)); LOG_WARN("fail to set all table partition for tsc", K(ret));
} }
} }
@ -942,7 +946,8 @@ int ObPXServerAddrUtil::set_dfo_accessed_location(ObExecContext &ctx,
int64_t base_table_location_key, int64_t base_table_location_key,
ObDfo &dfo, ObDfo &dfo,
ObIArray<const ObTableScanSpec *> &scan_ops, ObIArray<const ObTableScanSpec *> &scan_ops,
const ObTableModifySpec *dml_op) const ObTableModifySpec *dml_op,
ObDASTableLoc *dml_loc)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -958,13 +963,12 @@ int ObPXServerAddrUtil::set_dfo_accessed_location(ObExecContext &ctx,
LOG_WARN("get single table location id failed", K(ret)); LOG_WARN("get single table location id failed", K(ret));
} else { } else {
if (dml_op->is_table_location_uncertain()) { if (dml_op->is_table_location_uncertain()) {
CK(OB_NOT_NULL(ctx.get_my_session())); if (OB_ISNULL(dml_loc)) {
OZ(ObTableLocation::get_full_leader_table_loc(DAS_CTX(ctx).get_location_router(), ret = OB_ERR_UNEXPECTED;
ctx.get_allocator(), LOG_WARN("unexpected dml loc", K(ret));
ctx.get_my_session()->get_effective_tenant_id(), } else {
table_location_key, table_loc = dml_loc;
ref_table_id, }
table_loc));
} else { } else {
// 通过TSC或者DML获得当前的DFO的partition对应的location信息 // 通过TSC或者DML获得当前的DFO的partition对应的location信息
// 后续利用location信息构建对应的SQC meta // 后续利用location信息构建对应的SQC meta

View File

@ -201,7 +201,8 @@ private:
int64_t base_table_location_key, int64_t base_table_location_key,
ObDfo &dfo, ObDfo &dfo,
common::ObIArray<const ObTableScanSpec *> &scan_ops, common::ObIArray<const ObTableScanSpec *> &scan_ops,
const ObTableModifySpec* dml_op); const ObTableModifySpec* dml_op,
ObDASTableLoc *dml_loc);
/** /**
* Add the partition information (table_loc) involved in the * Add the partition information (table_loc) involved in the
* current phy_op to the corresponding SQC access location * current phy_op to the corresponding SQC access location