Fix the issue of inaccurate reading of multiple ranges in columnar storage for multiple partition scenarios

This commit is contained in:
wudidapaopao
2023-11-15 04:49:08 +00:00
committed by ob-robot
parent cceed73307
commit 96fbcde3a7
3 changed files with 13 additions and 11 deletions

View File

@ -599,7 +599,7 @@ void TestCOSSTableRowScanner::test_row_scan_and_column_scan_with_multi_range2()
OK(multi_scanner_.get_blockscan_start(start_row_id, range_idx, block_scan_state));
ASSERT_EQ(range_row_ids_[4].start_row_id_, start_row_id);
ASSERT_EQ(4, range_idx);
ASSERT_EQ(PENDING_BLOCK_SCAN, multi_scanner_.prefetcher_.block_scan_state_);
ASSERT_TRUE(PENDING_BLOCK_SCAN == multi_scanner_.prefetcher_.block_scan_state_ || IN_END_OF_RANGE == multi_scanner_.prefetcher_.block_scan_state_);
ASSERT_EQ(BLOCKSCAN_RANGE, block_scan_state);
forward_blockscan_to_end(&multi_scanner_, end_row_id, block_scan_state, is_reverse);
@ -676,14 +676,13 @@ void TestCOSSTableRowScanner::test_reverse_row_scan_and_column_scan_with_multi_r
OK(multi_scanner_.get_blockscan_start(start_row_id, range_idx, block_scan_state));
ASSERT_EQ(range_row_ids_[4].end_row_id_, start_row_id);
ASSERT_EQ(4, range_idx);
ASSERT_EQ(PENDING_BLOCK_SCAN, multi_scanner_.prefetcher_.block_scan_state_);
ASSERT_TRUE(PENDING_BLOCK_SCAN == multi_scanner_.prefetcher_.block_scan_state_ || IN_END_OF_RANGE == multi_scanner_.prefetcher_.block_scan_state_);
ASSERT_EQ(BLOCKSCAN_RANGE, block_scan_state);
forward_blockscan_to_end(&multi_scanner_, end_row_id, block_scan_state, is_reverse);
ASSERT_EQ(border_id1 + 1, end_row_id);
ASSERT_EQ(BLOCKSCAN_FINISH, block_scan_state);
consume_rows_by_row_store(&multi_scanner_, border_id1, range_row_ids_[4].start_row_id_,
is_reverse);
consume_rows_by_row_store(&multi_scanner_, border_id1, range_row_ids_[4].start_row_id_, is_reverse);
check_iter_end(&multi_scanner_);
}

View File

@ -1280,11 +1280,13 @@ OB_INLINE static int binary_check_micro_infos(
if (OB_UNLIKELY(check_border_idx > 0)) {
// move to left if the two rightmost endkeys is same(possible in multiple ranges)
int cmp_ret = 0;
for (; OB_SUCC(ret) && 0 == cmp_ret && check_border_idx > start; check_border_idx--) {
for (; OB_SUCC(ret) && check_border_idx > start; check_border_idx--) {
const ObDatumRowkey *cur_endkey = (micro_infos + check_border_idx)->endkey_;
const ObDatumRowkey *prev_endkey = (micro_infos + check_border_idx - 1)->endkey_;
if (OB_FAIL(cur_endkey->compare(*prev_endkey, datum_utils, cmp_ret, false))) {
LOG_WARN("fail to compare rowkey", K(ret), KPC(cur_endkey), KPC(prev_endkey));
} else if (cmp_ret != 0) {
break;
}
}
}

View File

@ -30,6 +30,9 @@ void ObCOPrefetcher::reuse()
set_range_scan_finish();
block_scan_border_row_id_ = OB_INVALID_CS_ROW_ID;
ObIndexTreeMultiPassPrefetcher::reuse();
for (int i = 0; i < max_range_prefetching_cnt_; ++i) {
read_handles_[i].reuse();
}
}
int ObCOPrefetcher::refresh_blockscan_checker(const int64_t start_micro_idx, const ObDatumRowkey &border_rowkey)
@ -258,7 +261,6 @@ int ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level(
const bool is_reverse = access_ctx_->query_flag_.is_reverse_scan();
ObSSTableReadHandle &read_handle = read_handles_[cur_range_fetch_idx_ % max_range_prefetching_cnt_];
int64_t micro_end_idx = read_handle.micro_end_idx_;
bool is_out_row_found = false;
// pos points to the next data micro block that we should open.
int64_t pos = start_micro_idx;
@ -271,7 +273,7 @@ int ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level(
pos = micro_end_idx + 1;
} else {
for (; pos <= micro_end_idx; ++pos) {
if (!micro_data_infos_[pos % max_micro_handle_cnt_].can_blockscan(false)) {
if (!micro_data_infos_[pos % max_micro_handle_cnt_].can_blockscan_) {
break;
}
}
@ -292,8 +294,7 @@ int ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level(
int32_t cur_block_scan_level = get_cur_level_of_block_scan();
if (pos <= micro_end_idx
|| INVALID_LEVEL == cur_block_scan_level
|| is_reverse
|| is_out_row_found) {
|| is_reverse) {
if (INVALID_LEVEL != cur_block_scan_level) {
reset_blockscan_for_target_level(cur_block_scan_level);
}
@ -307,10 +308,10 @@ int ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level(
K(pos), K_(block_scan_state));
}
LOG_DEBUG("ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level advance",
K(ret), K(start_micro_idx), K(pos), K(is_range_end), K(is_out_row_found), K_(block_scan_state));
K(ret), K(start_micro_idx), K(pos), K(is_range_end), K_(block_scan_state));
}
LOG_DEBUG("ObCOPrefetcher::refresh_blockscan_checker_in_leaf_level end",
K(ret), K(start_micro_idx), K(pos), K(border_rowkey), K(is_out_row_found), KPC(this));
K(ret), K(start_micro_idx), K(pos), K(border_rowkey), KPC(this));
return ret;
}