This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-2.0-alpha in repository https://gitbox.apache.org/repos/asf/doris.git
commit 03e3a225277a75efe7570a89474f624522ce5979 Author: airborne12 <airborn...@gmail.com> AuthorDate: Thu Apr 27 11:53:55 2023 +0800 [Fix](inverted index) fix memory leak for inverted index (#19008) forget to delete handler->_shared_lock --- .../inverted_index_compound_directory.cpp | 1 + .../rowset/segment_v2/inverted_index_writer.cpp | 39 ++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp index c3b474dfe1..94c0f8c47a 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp @@ -262,6 +262,7 @@ bool DorisCompoundDirectory::FSIndexInput::open(const io::FileSystemSPtr& fs, co error.set(CL_ERR_IO, "Could not open file"); } } + delete h->_shared_lock; _CLDECDELETE(h) return false; } diff --git a/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp b/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp index ae95408648..22512a7efe 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp @@ -321,32 +321,35 @@ public: //TODO: get size of inverted index return 0; } + void write_null_bitmap(lucene::store::IndexOutput* null_bitmap_out, + lucene::store::Directory* dir) { + // write null_bitmap file + _null_bitmap.runOptimize(); + size_t size = _null_bitmap.getSizeInBytes(false); + if (size > 0) { + null_bitmap_out = dir->createOutput( + InvertedIndexDescriptor::get_temporary_null_bitmap_file_name().c_str()); + faststring buf; + buf.resize(size); + _null_bitmap.write(reinterpret_cast<char*>(buf.data()), false); + null_bitmap_out->writeBytes(reinterpret_cast<uint8_t*>(buf.data()), size); + FINALIZE_OUTPUT(null_bitmap_out) + } + } Status finish() override { - auto index_path = InvertedIndexDescriptor::get_temporary_index_path( - _directory + "/" + _segment_file_name, _index_meta->index_id()); - lucene::store::Directory* dir = - DorisCompoundDirectory::getDirectory(_fs, index_path.c_str(), true); + lucene::store::Directory* dir = nullptr; lucene::store::IndexOutput* null_bitmap_out = nullptr; lucene::store::IndexOutput* data_out = nullptr; lucene::store::IndexOutput* index_out = nullptr; lucene::store::IndexOutput* meta_out = nullptr; try { - // write null_bitmap file - _null_bitmap.runOptimize(); - size_t size = _null_bitmap.getSizeInBytes(false); - if (size > 0) { - null_bitmap_out = dir->createOutput( - InvertedIndexDescriptor::get_temporary_null_bitmap_file_name().c_str()); - faststring buf; - buf.resize(size); - _null_bitmap.write(reinterpret_cast<char*>(buf.data()), false); - null_bitmap_out->writeBytes(reinterpret_cast<uint8_t*>(buf.data()), size); - FINALIZE_OUTPUT(null_bitmap_out) - } - // write bkd file if constexpr (field_is_numeric_type(field_type)) { + auto index_path = InvertedIndexDescriptor::get_temporary_index_path( + _directory + "/" + _segment_file_name, _index_meta->index_id()); + dir = DorisCompoundDirectory::getDirectory(_fs, index_path.c_str(), true); + write_null_bitmap(null_bitmap_out, dir); _bkd_writer->max_doc_ = _rid; _bkd_writer->docs_seen_ = _row_ids_seen_for_bkd; data_out = dir->createOutput( @@ -364,6 +367,8 @@ public: FINALIZE_OUTPUT(index_out) FINALIZE_OUTPUT(dir) } else if constexpr (field_is_slice_type(field_type)) { + dir = _index_writer->getDirectory(); + write_null_bitmap(null_bitmap_out, dir); close(); } } catch (CLuceneError& e) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org