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

fix memory release leak when load job's broker_scan_node fail #26

Merged
merged 2 commits into from
Aug 17, 2017
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
2 changes: 1 addition & 1 deletion be/src/exec/csv_scan_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Status CsvScanNode::close(RuntimeState* state) {

SCOPED_TIMER(_runtime_profile->total_time_counter());

if (memory_used_counter() != nullptr) {
if (memory_used_counter() != nullptr && _tuple_pool.get() != nullptr) {
COUNTER_UPDATE(memory_used_counter(), _tuple_pool->peak_allocated_bytes());
}

Expand Down
6 changes: 5 additions & 1 deletion be/src/runtime/data_spliter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ Status DataSpliter::close(RuntimeState* state, Status close_status) {
is_ok = false;
err_status = status;
}
iter.second->reset();
iter.second->clear();
}
}
} else {
for (const auto& iter : _batch_map) {
iter.second->clear();
}
}
// finish sink
for (const auto& iter : _dpp_sink_vec) {
Expand Down
11 changes: 10 additions & 1 deletion be/src/runtime/row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ RowBatch::RowBatch(const RowDescriptor& row_desc, const TRowBatch& input_batch,
}
}

RowBatch::~RowBatch() {
void RowBatch::clear() {
if (_cleared) {
return;
}

_tuple_data_pool->free_all();
for (int i = 0; i < _io_buffers.size(); ++i) {
_io_buffers[i]->return_buffer();
Expand All @@ -181,6 +185,11 @@ RowBatch::~RowBatch() {
_mem_tracker->release(_tuple_ptrs_size);
_tuple_ptrs = NULL;
}
_cleared = true;
}

RowBatch::~RowBatch() {
clear();
}

int RowBatch::serialize(TRowBatch* output_batch) {
Expand Down
4 changes: 4 additions & 0 deletions be/src/runtime/row_batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class RowBatch : public RowBatchInterface {
// - buffer handles from the io mgr
virtual ~RowBatch();

// used to c
void clear();

static const int INVALID_ROW_INDEX = -1;

// Add n rows of tuple pointers after the last committed row and return its index.
Expand Down Expand Up @@ -486,6 +489,7 @@ class RowBatch : public RowBatchInterface {
std::string _compression_scratch;

int _scanner_id;
bool _cleared = false;
};

/// Macros for iterating through '_row_batch', starting at '_start_row_idx'.
Expand Down