This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new ccff47e813d [Fix](inverted index) fix use after free when duplicate
key in index dir when index file writer open index #42207 (#42301)
ccff47e813d is described below
commit ccff47e813dcceba1195fc9a8b3f7effe356a368
Author: airborne12 <[email protected]>
AuthorDate: Wed Oct 23 16:45:25 2024 +0800
[Fix](inverted index) fix use after free when duplicate key in index dir
when index file writer open index #42207 (#42301)
cherry pick from #42207
---
.../rowset/segment_v2/inverted_index_file_writer.cpp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp
b/be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp
index 675c55bc77e..7b66ee70cbe 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp
@@ -59,7 +59,8 @@ Result<DorisFSDirectory*> InvertedIndexFileWriter::open(const
TabletIndex* index
}
if (exists) {
LOG(ERROR) << "try to init a directory:" << lfs_index_path << "
already exists";
- return ResultError(Status::InternalError("init_fulltext_index
directory already exists"));
+ return ResultError(
+ Status::InternalError("InvertedIndexFileWriter::open directory
already exists"));
}
bool can_use_ram_dir = true;
@@ -67,8 +68,18 @@ Result<DorisFSDirectory*>
InvertedIndexFileWriter::open(const TabletIndex* index
auto* dir = DorisFSDirectoryFactory::getDirectory(_lfs,
lfs_index_path.c_str(),
use_compound_file_writer, can_use_ram_dir,
nullptr, _fs,
index_path.c_str());
- _indices_dirs.emplace(std::make_pair(index_id, index_suffix),
- std::unique_ptr<DorisFSDirectory>(dir));
+ auto key = std::make_pair(index_id, index_suffix);
+ auto [it, inserted] = _indices_dirs.emplace(key,
std::unique_ptr<DorisFSDirectory>(dir));
+ if (!inserted) {
+ LOG(ERROR) << "InvertedIndexFileWriter::open attempted to insert a
duplicate key: ("
+ << key.first << ", " << key.second << ")";
+ LOG(ERROR) << "Directories already in map: ";
+ for (const auto& entry : _indices_dirs) {
+ LOG(ERROR) << "Key: (" << entry.first.first << ", " <<
entry.first.second << ")";
+ }
+ return ResultError(Status::InternalError(
+ "InvertedIndexFileWriter::open attempted to insert a duplicate
dir"));
+ }
return dir;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]