Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] fix nljoin with big array cause be oom (backport #55603) #55648

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions be/src/exec/pipeline/nljoin/nljoin_probe_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void NLJoinProbeOperator::_permute_chunk_base_right(ChunkPtr* chunk) {
// The chunk either consists two conditions:
// 1. Multiple probe rows and multiple build single-chunk
// 2. One probe rows and one build chunk
ChunkPtr NLJoinProbeOperator::_permute_chunk_for_other_join(size_t chunk_size) {
StatusOr<ChunkPtr> NLJoinProbeOperator::_permute_chunk_for_other_join(size_t chunk_size) {
// TODO: optimize the loop order for small build chunk
ChunkPtr chunk = _init_output_chunk(chunk_size);
bool probe_started = false;
Expand All @@ -483,7 +483,7 @@ ChunkPtr NLJoinProbeOperator::_permute_chunk_for_other_join(size_t chunk_size) {
// Last build chunk must permute a chunk
bool is_last_build_chunk = _curr_build_chunk_index == _num_build_chunks() - 1 && _num_build_chunks() > 1;
if (!_probe_row_finished && is_last_build_chunk) {
_permute_probe_row(chunk);
RETURN_IF_ERROR(_permute_probe_row(chunk));
_reset_build_chunk_index();
_probe_row_finished = true;
probe_row_start();
Expand All @@ -493,7 +493,7 @@ ChunkPtr NLJoinProbeOperator::_permute_chunk_for_other_join(size_t chunk_size) {
// For SEMI/ANTI JOIN, the probe-row could be skipped once find matched/unmatched
// Otherwise accumulate more build chunks into a larger chunk
while (!_probe_row_finished && _curr_build_chunk_index < _num_build_chunks()) {
_permute_probe_row(chunk);
RETURN_IF_ERROR(_permute_probe_row(chunk));
_next_build_chunk_index_for_other_join();
probe_row_start();
if (chunk->num_rows() >= chunk_size) {
Expand All @@ -510,10 +510,11 @@ ChunkPtr NLJoinProbeOperator::_permute_chunk_for_other_join(size_t chunk_size) {
}

// Permute one probe row with current build chunk
void NLJoinProbeOperator::_permute_probe_row(const ChunkPtr& chunk) {
Status NLJoinProbeOperator::_permute_probe_row(const ChunkPtr& chunk) {
DCHECK(_curr_build_chunk);
size_t cur_build_chunk_rows = _curr_build_chunk->num_rows();
COUNTER_UPDATE(_permute_rows_counter, cur_build_chunk_rows);
TRY_CATCH_ALLOC_SCOPE_START()
for (size_t i = 0; i < _col_types.size(); i++) {
bool is_probe = i < _probe_column_count;
SlotDescriptor* slot = _col_types[i];
Expand All @@ -526,6 +527,8 @@ void NLJoinProbeOperator::_permute_probe_row(const ChunkPtr& chunk) {
dst_col->append(*src_col);
}
}
TRY_CATCH_ALLOC_SCOPE_END()
return Status::OK();
}

// Permute probe side for left join
Expand Down Expand Up @@ -630,7 +633,7 @@ StatusOr<ChunkPtr> NLJoinProbeOperator::_pull_chunk_for_other_join(size_t chunk_
return chunk;
}
while (!_is_curr_probe_chunk_finished()) {
ChunkPtr chunk = _permute_chunk_for_other_join(chunk_size);
ASSIGN_OR_RETURN(ChunkPtr chunk, _permute_chunk_for_other_join(chunk_size));
DCHECK(chunk);
RETURN_IF_ERROR(_probe_for_other_join(chunk));
RETURN_IF_ERROR(eval_conjuncts(_conjunct_ctxs, chunk.get(), nullptr));
Expand Down
4 changes: 2 additions & 2 deletions be/src/exec/pipeline/nljoin/nljoin_probe_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class NLJoinProbeOperator final : public OperatorWithDependency {
bool _skip_probe() const;
void _check_post_probe() const;
void _init_build_match() const;
void _permute_probe_row(const ChunkPtr& chunk);
ChunkPtr _permute_chunk_for_other_join(size_t chunk_size);
Status _permute_probe_row(const ChunkPtr& chunk);
StatusOr<ChunkPtr> _permute_chunk_for_other_join(size_t chunk_size);
ChunkPtr _permute_chunk_for_inner_join(size_t chunk_size);
void _permute_chunk_base_left(ChunkPtr* chunk);
void _permute_chunk_base_right(ChunkPtr* chunk);
Expand Down
Loading