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](inverted index) fix use after free when duplicate key in index dir when index file writer open index #42207

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
18 changes: 15 additions & 3 deletions be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,26 @@ Result<DorisFSDirectory*> InvertedIndexFileWriter::open(const TabletIndex* index

if (exists) {
LOG(ERROR) << "try to init a directory:" << local_fs_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;
auto* dir = DorisFSDirectoryFactory::getDirectory(local_fs, local_fs_index_path.c_str(),
can_use_ram_dir);
_indices_dirs.emplace(std::make_pair(index_meta->index_id(), index_meta->get_index_suffix()),
std::unique_ptr<DorisFSDirectory>(dir));
auto key = std::make_pair(index_meta->index_id(), index_meta->get_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;
}

Expand Down
Loading