[CP] fix partition wise join and global index lookup -4016

This commit is contained in:
leslieyuchen
2023-11-02 05:12:51 +00:00
committed by ob-robot
parent 52efbcb6b0
commit 38d3830962
2 changed files with 40 additions and 13 deletions

View File

@ -136,20 +136,41 @@ int ObSubQueryIterator::rewind(const bool reset_onetime_plan /* = false */)
} }
if (OB_SUCC(ret) && current_group_ < parent_spf_group) { if (OB_SUCC(ret) && current_group_ < parent_spf_group) {
if (new_group) { if (new_group) {
//If in lookup op, we need to call get next row to init all of iter. /**
op_.get_next_row(); * Since the initialization of the lookup Iterator is done within index_lookup.get_next_row(),
} * when SPF enters skip scan,
int64_t old_jump_read_group_id; * we need to mark the jump_read_group_id for each scan Iterator
old_jump_read_group_id = op_.get_exec_ctx().get_das_ctx().jump_read_group_id_; * and determine the number of rows to skip based on the current group_id.
op_.get_exec_ctx().get_das_ctx().jump_read_group_id_ = parent_spf_group; * The issue with the lookup process here is that when SPF performs multiple skip scans,
if (OB_FAIL(op_.rescan())) { * the lookup process may not be executed at all,
if(OB_ITER_END == ret) { * resulting in uninitialized lookup Iterators.
ret = OB_ERR_UNEXPECTED; * As a result, when subsequent skip reads occur,
* the lookup Iterator will not be set with the correct jum_read_group_id.
* Therefore, it is necessary to ensure that get_next_row() is called at least once to
* initialize the lookup Iterator on the right branch.
**/
if (OB_FAIL(op_.get_next_row())) {
if (OB_ITER_END == ret) {
//ignore OB_ITER_END
ret = OB_SUCCESS;
} else {
LOG_WARN("get next row from child failed", K(ret));
}
} }
LOG_WARN("Das jump read rescan fail.", K(ret));
} }
op_.get_exec_ctx().get_das_ctx().jump_read_group_id_ = old_jump_read_group_id; if (OB_SUCC(ret)) {
current_group_ = parent_spf_group; int64_t old_jump_read_group_id;
old_jump_read_group_id = op_.get_exec_ctx().get_das_ctx().jump_read_group_id_;
op_.get_exec_ctx().get_das_ctx().jump_read_group_id_ = parent_spf_group;
if (OB_FAIL(op_.rescan())) {
if(OB_ITER_END == ret) {
ret = OB_ERR_UNEXPECTED;
}
LOG_WARN("Das jump read rescan fail.", K(ret));
}
op_.get_exec_ctx().get_das_ctx().jump_read_group_id_ = old_jump_read_group_id;
current_group_ = parent_spf_group;
}
} }
} }
} else { } else {

View File

@ -1652,6 +1652,9 @@ bool ObTableScanOp::need_real_rescan()
bool bret = false; bool bret = false;
if (!MY_SPEC.batch_scan_flag_) { if (!MY_SPEC.batch_scan_flag_) {
bret = true; bret = true;
} else if (tsc_rtdef_.bnlj_params_.empty()) {
//batch rescan not init, need to do real rescan
bret = true;
} else { } else {
ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_); ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_);
int64_t param_idx = tsc_rtdef_.bnlj_params_.at(0).param_idx_; int64_t param_idx = tsc_rtdef_.bnlj_params_.at(0).param_idx_;
@ -3059,7 +3062,10 @@ int ObGlobalIndexLookupOpImpl::close()
int ObGlobalIndexLookupOpImpl::rescan() int ObGlobalIndexLookupOpImpl::rescan()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (get_batch_rescan() && lookup_group_cnt_ < index_group_cnt_) { if (OB_ISNULL(table_scan_op_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("table scan op not init", K(ret));
} else if (!table_scan_op_->need_real_rescan() && lookup_group_cnt_ < index_group_cnt_) {
LOG_DEBUG("rescan in group lookup, only need to switch iterator", LOG_DEBUG("rescan in group lookup, only need to switch iterator",
K(lookup_group_cnt_), K(index_group_cnt_)); K(lookup_group_cnt_), K(index_group_cnt_));
if (OB_FAIL(table_scan_op_->build_bnlj_params())) { if (OB_FAIL(table_scan_op_->build_bnlj_params())) {