Skip to content

Commit

Permalink
fix: querynode hang when failing to allocate disk space for mmap(#35184)
Browse files Browse the repository at this point in the history
Signed-off-by: MrPresent-Han <[email protected]>
  • Loading branch information
MrPresent-Han committed Aug 12, 2024
1 parent 06f9ba2 commit f324c2b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions internal/core/src/storage/ChunkCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,36 @@ ChunkCache::Read(const std::string& filepath,

// release lock and perform download and decode
// other thread request same path shall get the future.
auto field_data = DownloadAndDecodeRemoteFile(cm_.get(), filepath);
auto column = Mmap(field_data->GetFieldData(), descriptor);

// set promise value to notify the future
lck.lock();
std::unique_ptr<DataCodec> field_data;
std::shared_ptr<ColumnBase> column;
bool allocate_success = false;
ErrorCode err_code = Success;
std::string err_msg = "";
try {
field_data = DownloadAndDecodeRemoteFile(cm_.get(), filepath);
column = Mmap(field_data->GetFieldData(), descriptor);
allocate_success = true;
} catch(const SegcoreError& e) {
err_code = e.get_error_code();
err_msg = fmt::format(
"failed to read for chunkCache, seg_core_err:{}",
e.what());
}
std::unique_lock mmap_lck(mutex_);
it = columns_.find(filepath);
if (it != columns_.end()) {
// check pair exists then set value
it->second.first.set_value(column);
if(allocate_success) {
AssertInfo(column, "unexpected null column, file={}", filepath);
}
} else {
PanicInfo(UnexpectedError, "Wrong code, the thread to download for cache should get the target entry");
}
if(err_code != Success) {
columns_.erase(filepath);
throw SegcoreError(err_code, err_msg);
}
lck.unlock();
AssertInfo(column, "unexpected null column, file={}", filepath);
return column;
}

Expand Down

0 comments on commit f324c2b

Please sign in to comment.