This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new f4dbf83eeea [Pick 2.0](inverted index) fix inverted index compound
reader memory leak (#36384)
f4dbf83eeea is described below
commit f4dbf83eeea240760e36bff2661b59669f1e6874
Author: airborne12 <[email protected]>
AuthorDate: Tue Jun 18 16:13:14 2024 +0800
[Pick 2.0](inverted index) fix inverted index compound reader memory leak
(#36384)
## Proposed changes
Issue Number: close #xxx
Pick from #36146
---
.../segment_v2/inverted_index_compound_reader.cpp | 25 ++++++++++++++++------
.../segment_v2/inverted_index_compound_reader.h | 7 +++---
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.cpp
b/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.cpp
index fce1009be51..6673845b89c 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.cpp
@@ -129,7 +129,6 @@
DorisCompoundReader::DorisCompoundReader(lucene::store::Directory* d, const char
dir(d),
ram_dir(new lucene::store::RAMDirectory()),
file_name(name),
- stream(nullptr),
entries(_CLNEW EntriesType(true, true)) {
bool success = false;
try {
@@ -209,6 +208,13 @@ void DorisCompoundReader::copyFile(const char* file,
int64_t file_length, uint8_
}
DorisCompoundReader::~DorisCompoundReader() {
+ if (!_closed) {
+ try {
+ close();
+ } catch (CLuceneError& err) {
+ LOG(ERROR) << "DorisCompoundReader finalize error:" << err.what();
+ }
+ }
_CLDELETE(entries)
}
@@ -292,14 +298,21 @@ bool DorisCompoundReader::openInput(const char* name,
lucene::store::IndexInput*
void DorisCompoundReader::close() {
std::lock_guard<std::mutex> wlock(_this_lock);
if (stream != nullptr) {
- entries->clear();
stream->close();
_CLDELETE(stream)
}
- ram_dir->close();
- dir->close();
- _CLDECDELETE(dir)
- _CLDELETE(ram_dir)
+ if (entries != nullptr) {
+ entries->clear();
+ }
+ if (ram_dir) {
+ ram_dir->close();
+ _CLDELETE(ram_dir)
+ }
+ if (dir) {
+ dir->close();
+ _CLDECDELETE(dir)
+ }
+ _closed = true;
}
bool DorisCompoundReader::doDeleteFile(const char* /*name*/) {
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.h
b/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.h
index 75bf1ab633e..c084141c656 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_reader.h
@@ -34,11 +34,9 @@
class CLuceneError;
-namespace lucene {
-namespace store {
+namespace lucene::store {
class RAMDirectory;
-} // namespace store
-} // namespace lucene
+} // namespace lucene::store
namespace doris {
@@ -66,6 +64,7 @@ private:
EntriesType* entries;
std::mutex _this_lock;
+ bool _closed = false;
protected:
/** Removes an existing file in the directory-> */
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]