fix multi cf query mem leak

This commit is contained in:
stuBirFly 2025-01-03 06:45:57 +00:00 committed by ob-robot
parent 003bf059ea
commit 64d36d83bb

View File

@ -36,6 +36,9 @@ public:
binary_heap_.at(i) = nullptr;
}
}
for (int j = 0; j < inner_result_iters_.count(); j++) {
ObTableQueryUtils::destroy_result_iterator(inner_result_iters_.at(j));
}
allocator_.reset();
}
@ -231,6 +234,7 @@ int ObMergeTableQueryResultIterator<Row, Compare>::get_next_result(ObTableQueryR
int curr_row_count = 0;
while (OB_SUCC(ret) && has_more_result() && one_result_->get_row_count() < batch && curr_row_count <= caching) {
ObRowCacheIterator *cache_iterator = binary_heap_.top();
bool in_heap = true;
ObString curr_iter_key = cache_iterator->row_.get_cell(ObHTableConstants::COL_IDX_K).get_string();
if (curr_key.compare(curr_iter_key) != 0) {
curr_row_count++;
@ -240,6 +244,7 @@ int ObMergeTableQueryResultIterator<Row, Compare>::get_next_result(ObTableQueryR
}
} else if (OB_FAIL(binary_heap_.pop())) {
SERVER_LOG(WARN, "fail to pop items", K(ret));
} else if (FALSE_IT(in_heap = false)) {
} else if (OB_FAIL(compare_.get_error_code())) {
SERVER_LOG(WARN, "fail to compare items", K(ret));
} else if (OB_FAIL(one_result_->add_row(cache_iterator->row_))) {
@ -248,7 +253,6 @@ int ObMergeTableQueryResultIterator<Row, Compare>::get_next_result(ObTableQueryR
// Clean up rows that have already been serialized to response
cache_iterator->allocator_.reuse();
Row row;
bool is_iter_valid = false;
if (OB_FAIL(cache_iterator->get_next_row(row))) {
if (ret != OB_ITER_END) {
SERVER_LOG(WARN, "fail to get next row from ObRowCacheIterator");
@ -257,9 +261,8 @@ int ObMergeTableQueryResultIterator<Row, Compare>::get_next_result(ObTableQueryR
if (row.is_valid()) {
if (OB_FAIL(ob_write_row(cache_iterator->allocator_, row, cache_iterator->row_))) {
SERVER_LOG(WARN, "fail to copy row", K(ret));
} else if (OB_FAIL(binary_heap_.push(cache_iterator))) {
} else if (OB_FAIL(binary_heap_.push(cache_iterator, in_heap))) {
SERVER_LOG(WARN, "fail to push items", K(ret));
} else if (FALSE_IT(is_iter_valid = true)) {
} else if (OB_FAIL(compare_.get_error_code())) {
SERVER_LOG(WARN, "fail to compare items", K(ret));
}
@ -268,16 +271,16 @@ int ObMergeTableQueryResultIterator<Row, Compare>::get_next_result(ObTableQueryR
} else {
if (OB_FAIL(ob_write_row(cache_iterator->allocator_, row, cache_iterator->row_))) {
SERVER_LOG(WARN, "fail to copy row", K(ret));
} else if (OB_FAIL(binary_heap_.push(cache_iterator))) {
} else if (OB_FAIL(binary_heap_.push(cache_iterator, in_heap))) {
SERVER_LOG(WARN, "fail to push items", K(ret));
} else if (FALSE_IT(is_iter_valid = true)) {
} else if (OB_FAIL(compare_.get_error_code())) {
SERVER_LOG(WARN, "fail to compare items", K(ret));
}
}
if (!is_iter_valid) {
cache_iterator->~ObRowCacheIterator();
}
}
if (!in_heap && OB_NOT_NULL(cache_iterator)) {
cache_iterator->~ObRowCacheIterator();
allocator_.free(cache_iterator);
}
}
}