Skip to content

Commit 549023c

Browse files
zhangheiheimergify[bot]
authored andcommitted
[BugFix]Fix filesystem cache failure. (#65823)
Signed-off-by: edwinhzhang <[email protected]> Signed-off-by: edwinhzhang <[email protected]> (cherry picked from commit 06a0a19)
1 parent 2306d4f commit 549023c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

be/src/service/staros_worker.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,15 @@ absl::StatusOr<std::shared_ptr<fslib::FileSystem>> StarOSWorker::get_shard_files
202202
return build_filesystem_on_demand(id, conf);
203203
}
204204

205-
auto fs = lookup_fs_cache(it->second.fs_cache_key);
206-
if (fs != nullptr) {
207-
return fs;
205+
// Cache miss: reset the fs_cache_key to ensure a new shared_ptr will be created
206+
{
207+
std::lock_guard<std::mutex> reset_lock(_fs_cache_key_reset_mtx);
208+
auto fs = lookup_fs_cache(it->second.fs_cache_key);
209+
if (fs != nullptr) {
210+
return fs;
211+
}
212+
213+
it->second.fs_cache_key.reset();
208214
}
209215
shard_info = it->second.shard_info;
210216
}

be/src/service/staros_worker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class StarOSWorker : public staros::starlet::Worker {
124124
private:
125125
mutable std::shared_mutex _mtx;
126126
std::shared_mutex _cache_mtx;
127+
std::mutex _fs_cache_key_reset_mtx; // Protects fs_cache_key reset operations
127128
std::unordered_map<ShardId, ShardInfoDetails> _shards;
128129
std::unique_ptr<Cache> _fs_cache;
129130
};

0 commit comments

Comments
 (0)