Skip to content

Commit

Permalink
Fix unstable cpp ut (milvus-io#28083)
Browse files Browse the repository at this point in the history
Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper authored Nov 1, 2023
1 parent 854c0e8 commit 873b29e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
9 changes: 1 addition & 8 deletions internal/core/src/storage/ChunkCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ ChunkCache::Read(const std::string& filepath) {
strerror(errno)));

columns_.emplace(path, column);
mmap_file_locks_.erase(path);
return column;
}

Expand Down Expand Up @@ -71,13 +70,7 @@ ChunkCache::Prefetch(const std::string& filepath) {
std::shared_ptr<ColumnBase>
ChunkCache::Mmap(const std::filesystem::path& path,
const FieldDataPtr& field_data) {
MmapFileLocks::accessor acc;
if (!mmap_file_locks_.find(acc, path)) {
mmap_file_locks_.insert(
acc, std::make_pair(path, std::make_unique<std::mutex>()));
}
std::unique_lock lck(*acc->second.get());
acc.release();
std::unique_lock lck(mutex_);

auto dir = path.parent_path();
std::filesystem::create_directories(dir);
Expand Down
6 changes: 1 addition & 5 deletions internal/core/src/storage/ChunkCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ class ChunkCache {
oneapi::tbb::concurrent_hash_map<std::string,
std::shared_ptr<ColumnBase>>;

using MmapFileLocks =
oneapi::tbb::concurrent_hash_map<std::string,
std::unique_ptr<std::mutex>>;

private:
MmapFileLocks mmap_file_locks_;
mutable std::mutex mutex_;
int read_ahead_policy_;
std::string path_prefix_;
ChunkManagerPtr cm_;
Expand Down

0 comments on commit 873b29e

Please sign in to comment.