Fix sample block return no data bug and sanity core

This commit is contained in:
haitaoyang
2023-07-06 06:47:57 +00:00
committed by ob-robot
parent d4093399b2
commit 137d8876a3
2 changed files with 18 additions and 7 deletions

View File

@ -100,7 +100,7 @@ int ObBlockSampleSSTableEndkeyIterator::open(
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
is_inited_ = true; is_inited_ = true;
} }
STORAGE_LOG(TRACE, "open iter", K(ret), K(macro_count_), K(micro_count_), K(sstable));
} }
return ret; return ret;
@ -372,7 +372,11 @@ int ObBlockSampleRangeIterator::get_next_range(const ObDatumRange *&range)
STORAGE_LOG(WARN, "Fail to deep copy to current key", K(ret), KPC(min_iter)); STORAGE_LOG(WARN, "Fail to deep copy to current key", K(ret), KPC(min_iter));
} else if (FALSE_IT(generate_cur_range(curr_key_.key_))) { } else if (FALSE_IT(generate_cur_range(curr_key_.key_))) {
} else if (OB_FAIL(move_endkey_iter(*min_iter))) { } else if (OB_FAIL(move_endkey_iter(*min_iter))) {
STORAGE_LOG(WARN, "Fail to move forward endkey iterator", K(ret), K(*min_iter)); if (OB_ITER_END == ret) {
ret = OB_SUCCESS;
} else {
STORAGE_LOG(WARN, "Fail to move forward endkey iterator", K(ret), K(*min_iter));
}
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
range = &curr_range_; range = &curr_range_;
@ -451,18 +455,23 @@ int ObBlockSampleRangeIterator::calculate_level_and_batch_size(const double perc
micro_count += endkey_iters_[i]->get_micro_count(); micro_count += endkey_iters_[i]->get_micro_count();
} }
if (macro_count > macro_threshold) { if (macro_count > macro_threshold) {
// macro level // switch to macro level, reset previous info
curr_key_.reset();
endkey_heap_.reset();
batch_size_ = macro_count * percent / 100 / EXPECTED_OPEN_RANGE_NUM; batch_size_ = macro_count * percent / 100 / EXPECTED_OPEN_RANGE_NUM;
for (int64_t i = 0 ; OB_SUCC(ret) && i < endkey_iters_.count() ; ++i) { for (int64_t i = 0 ; OB_SUCC(ret) && i < endkey_iters_.count() ; ++i) {
if (OB_FAIL(endkey_iters_[i]->upgrade_to_macro(*sample_range_))) { ObBlockSampleSSTableEndkeyIterator *iter = endkey_iters_[i];
if (OB_FAIL(iter->upgrade_to_macro(*sample_range_))) {
STORAGE_LOG(WARN, "Fail to upgrade to macro level", K(ret)); STORAGE_LOG(WARN, "Fail to upgrade to macro level", K(ret));
} else if (!iter->is_reach_end() && OB_FAIL(endkey_heap_.push(iter))) {
STORAGE_LOG(WARN, "Fail to push endkey heap", K(ret), K(iter), K(endkey_heap_));
} }
} }
} else { } else {
// micro level // micro level
batch_size_ = micro_count * percent / 100 / EXPECTED_OPEN_RANGE_NUM; batch_size_ = micro_count * percent / 100 / EXPECTED_OPEN_RANGE_NUM;
} }
STORAGE_LOG(TRACE, "calculate", K(ret), K(macro_count), K(micro_count), K(macro_threshold), K(batch_size_));
return ret; return ret;
} }
@ -550,7 +559,9 @@ int ObBlockSampleRangeIterator::move_endkey_iter(ObBlockSampleSSTableEndkeyItera
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
STORAGE_LOG(WARN, "ObBlockSampleRangeIterator is not inited", K(ret), KP(allocator_)); STORAGE_LOG(WARN, "ObBlockSampleRangeIterator is not inited", K(ret), KP(allocator_));
} else if (OB_FAIL(iter.move_forward())) { } else if (OB_FAIL(iter.move_forward())) {
STORAGE_LOG(WARN, "Fail to move forward endkey iter", K(ret), K(iter)); if (OB_UNLIKELY(OB_ITER_END != ret)) {
STORAGE_LOG(WARN, "Fail to move forward endkey iter", K(ret), K(iter));
}
} else if (!iter.is_reach_end() && OB_FAIL(endkey_heap_.push(&iter))) { } else if (!iter.is_reach_end() && OB_FAIL(endkey_heap_.push(&iter))) {
STORAGE_LOG(WARN, "Fail to push endkey heap", K(ret), K(iter), K(endkey_heap_)); STORAGE_LOG(WARN, "Fail to push endkey heap", K(ret), K(iter), K(endkey_heap_));
} }

View File

@ -929,7 +929,7 @@ int ObIndexBlockTreeCursor::estimate_range_macro_count(const ObDatumRange &range
if (OB_FAIL(locate_range_in_curr_block(range, begin_idx, end_idx))) { if (OB_FAIL(locate_range_in_curr_block(range, begin_idx, end_idx))) {
LOG_WARN("Fail to locate range in current block", K(ret), K(range)); LOG_WARN("Fail to locate range in current block", K(ret), K(range));
} else { } else {
micro_count = end_idx - begin_idx; micro_count = end_idx - begin_idx + 1;
} }
} else { } else {
micro_count = micro_count * curr_path_item_->row_count_; micro_count = micro_count * curr_path_item_->row_count_;