This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new cd4fec8 [Bug] Fix core of double delete, when RowBatch call transfer_resource_ownership (#4052) cd4fec8 is described below commit cd4fec8ab1bc74bd0b2b6d28aee1ef23fd05b835 Author: HappenLee <happen...@hotmail.com> AuthorDate: Mon Jul 13 20:52:22 2020 +0800 [Bug] Fix core of double delete, when RowBatch call transfer_resource_ownership (#4052) Resource release should be done by dest RowBatch. When we call method transfer_resource_ownership. if we don't clear the corresponding resources, which will cause the core problem of double delete. --- be/src/runtime/row_batch.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/be/src/runtime/row_batch.cpp b/be/src/runtime/row_batch.cpp index a35b8f1..4cfd953 100644 --- a/be/src/runtime/row_batch.cpp +++ b/be/src/runtime/row_batch.cpp @@ -524,21 +524,28 @@ void RowBatch::transfer_resource_ownership(RowBatch* dest) { dest->_auxiliary_mem_usage += buffer->buffer_len(); buffer->set_mem_tracker(dest->_mem_tracker); } + _io_buffers.clear(); for (BufferInfo& buffer_info : _buffers) { dest->add_buffer( buffer_info.client, std::move(buffer_info.buffer), FlushMode::NO_FLUSH_RESOURCES); } + _buffers.clear(); for (int i = 0; i < _tuple_streams.size(); ++i) { dest->_tuple_streams.push_back(_tuple_streams[i]); dest->_auxiliary_mem_usage += _tuple_streams[i]->byte_size(); } + // Resource release should be done by dest RowBatch. if we don't clear the corresponding resources. + // This Rowbatch calls the reset() method, dest Rowbatch will also call the reset() method again, + // which will cause the core problem of double delete + _tuple_streams.clear(); for (int i = 0; i < _blocks.size(); ++i) { dest->_blocks.push_back(_blocks[i]); dest->_auxiliary_mem_usage += _blocks[i]->buffer_len(); } + _blocks.clear(); dest->_need_to_return |= _need_to_return; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org