Skip to content

Commit

Permalink
[fix](multi table) fix single stream multi table memory leak (#38255) (
Browse files Browse the repository at this point in the history
…#38824)

pick (#38255)

We meet OOM when using single stream multi table


![image](https://github.com/user-attachments/assets/748e9914-d591-4f41-8b28-412d3cecc841)

It exist memory leak, and heap profile like:


![image](https://github.com/user-attachments/assets/af30c593-88ea-44f6-bba1-82436b13f99f)

The stream load context will not release in some exception conditions as
plan failed for high concurrency causing timeout when obtaining read
lock. It is introduced by #35458

The solution effect is shown in the following figure, which can run
stably with a small amount of memory


![image](https://github.com/user-attachments/assets/4483e0a5-6c0c-4cdc-b8ed-3408da6a86b2)
  • Loading branch information
sollhui authored Aug 4, 2024
1 parent 8e4fad9 commit 6035eda
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions be/src/io/fs/multi_table_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@ void MultiTablePipe::_handle_consumer_finished() {
_ctx->number_filtered_rows = _number_filtered_rows;
_ctx->number_unselected_rows = _number_unselected_rows;
_ctx->commit_infos = _tablet_commit_infos;

// remove ctx to avoid memory leak.
for (const auto& pair : _planned_tables) {
if (pair.second) {
doris::ExecEnv::GetInstance()->new_load_stream_mgr()->remove(pair.second->id);
}
}
for (const auto& pair : _unplanned_tables) {
if (pair.second) {
doris::ExecEnv::GetInstance()->new_load_stream_mgr()->remove(pair.second->id);
}
}

LOG(INFO) << "all plan for multi-table load complete. number_total_rows="
<< _ctx->number_total_rows << " number_loaded_rows=" << _ctx->number_loaded_rows
<< " number_filtered_rows=" << _ctx->number_filtered_rows
Expand Down

0 comments on commit 6035eda

Please sign in to comment.