fix execute dist plan report error when truncate table concurrently.

This commit is contained in:
sdc
2024-03-01 04:44:45 +00:00
committed by ob-robot
parent fbfce65499
commit 21caebcd16
3 changed files with 34 additions and 11 deletions

View File

@ -881,6 +881,7 @@ int ObGranuleIteratorOp::do_join_filter_partition_pruning(
if (OB_FAIL(try_build_tablet2part_id_map())) {
LOG_WARN("fail to build tablet2part id map", K(ret));
} else if (OB_FAIL(tablet2part_id_map_.get_refactored(tablet_id, part_id))) {
ret = OB_HASH_NOT_EXIST == ret ? OB_SCHEMA_ERROR : ret;
LOG_WARN("fail to get refactored part id", K(ret), K(tablet_id), K(part_id));
} else {
tablet_id = part_id;

View File

@ -1116,7 +1116,8 @@ int ObAffinitizeGranuleSplitter::split_tasks_affinity(ObExecContext &ctx,
if (is_virtual_table(table_schema->get_table_id())) {
tablet_idx = tablet_loc.tablet_id_.id() + 1;
} else if (OB_FAIL(idx_map.get_refactored(tablet_loc.tablet_id_.id(), tablet_idx))) {
LOG_WARN("fail to get tablet idx", K(ret));
ret = OB_HASH_NOT_EXIST == ret ? OB_SCHEMA_ERROR : ret;
LOG_WARN("fail to get tablet idx", K(ret), K(tablet_loc), KPC(table_schema));
}
}
if (OB_FAIL(ret)) {

View File

@ -518,9 +518,22 @@ int ObSlaveMapPkeyRandomIdxCalc::get_slice_indexes_inner(const ObIArray<ObExpr*>
LOG_WARN("failed to get partition id", K(ret));
} else if (OB_FAIL(get_task_idx_by_tablet_id(tablet_id, slice_idx_array.at(0)))) {
if (OB_HASH_NOT_EXIST == ret) {
// 没有找到对应的分区,返回OB_NO_PARTITION_FOR_GIVEN_VALUE
if (tablet_id <= 0) {
// tablet_id <= means this row matches no partition
ret = OB_NO_PARTITION_FOR_GIVEN_VALUE;
LOG_WARN("can't get the right partition", K(ret), K(tablet_id), K(slice_idx_array.at(0)));
} else {
// there are two scenarios tablet_id > 0.
// 1. insert into t partition (p0) select * from t partition (p1).
// tablet_id equals to tablet id of p1 but the map only contains tablet id of p0.
// 2. insert into t and truncate t concurrently. truncate t will make t maps to a new group of tablets.
// It's hard to distinct these two scenarios, so we report OB_SCHEMA_ERROR
// and record error msg of OB_NO_PARTITION_FOR_GIVEN_VALUE.
// As a result, if schema has changed, this query will be retried.
// Otherwise, error msg of OB_NO_PARTITION_FOR_GIVEN_VALUE will be reported to the client.
ret = OB_SCHEMA_ERROR;
LOG_USER_ERROR(OB_NO_PARTITION_FOR_GIVEN_VALUE);
}
LOG_WARN("can't get the right partition", K(ret), K(tablet_id), K(slice_idx_array.at(0)), K(repart_type_));
}
}
return ret;
@ -545,9 +558,13 @@ int ObSlaveMapPkeyRandomIdxCalc::get_slice_idx_batch_inner(const ObIArray<ObExpr
for (int64_t i = 0; i < batch_size && OB_SUCC(ret); i++) {
if (OB_FAIL(get_task_idx_by_tablet_id(tablet_ids_[i], slice_indexes_[i]))) {
if (OB_HASH_NOT_EXIST == ret) {
// 没有找到对应的分区,返回OB_NO_PARTITION_FOR_GIVEN_VALUE
if (tablet_ids_[i] <= 0) {
ret = OB_NO_PARTITION_FOR_GIVEN_VALUE;
LOG_WARN("can't get the right partition", K(ret), K(tablet_ids_[i]));
} else {
ret = OB_SCHEMA_ERROR;
LOG_USER_ERROR(OB_NO_PARTITION_FOR_GIVEN_VALUE);
}
LOG_WARN("can't get the right partition", K(ret), K(tablet_ids_[i]), K(repart_type_));
}
}
}
@ -1387,7 +1404,7 @@ int ObSlaveMapPkeyRangeIdxCalc::get_task_idx(
LOG_WARN("not init", K(ret), K(is_inited_));
} else if (OB_UNLIKELY(tablet_id <= 0)) {
ret = OB_NO_PARTITION_FOR_GIVEN_VALUE;
LOG_WARN("can't get the right partition", K(ret), K(tablet_id));
LOG_WARN("can't get the right partition", K(ret), K(tablet_id), K(repart_type_));
} else if (OB_UNLIKELY(sort_key.count() <= 0)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid argument", K(ret), K(tablet_id), K(sort_key));
@ -1513,9 +1530,13 @@ int ObSlaveMapPkeyHashIdxCalc::get_slice_indexes_inner(const ObIArray<ObExpr*> &
LOG_WARN("failed to get partition id", K(ret));
} else if (OB_FAIL(get_task_idx_by_tablet_id(eval_ctx, tablet_id, slice_idx_array.at(0)))) {
if (OB_HASH_NOT_EXIST == ret) {
// 没有找到对应的分区,返回OB_NO_PARTITION_FOR_GIVEN_VALUE
if (tablet_id <= 0) {
ret = OB_NO_PARTITION_FOR_GIVEN_VALUE;
LOG_WARN("can't get the right partition", K(ret), K(tablet_id));
} else {
ret = OB_SCHEMA_ERROR;
LOG_USER_ERROR(OB_NO_PARTITION_FOR_GIVEN_VALUE);
}
LOG_WARN("can't get the right partition", K(ret), K(tablet_id), K(repart_type_));
}
}
return ret;