Skip to content

Commit cfb4bbb

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 1052b5d commit cfb4bbb

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
@@ -221,9 +221,15 @@ absl::StatusOr<std::shared_ptr<fslib::FileSystem>> StarOSWorker::get_shard_files
221221
return build_filesystem_on_demand(id, conf);
222222
}
223223

224-
auto fs = lookup_fs_cache(it->second.fs_cache_key);
225-
if (fs != nullptr) {
226-
return fs;
224+
// Cache miss: reset the fs_cache_key to ensure a new shared_ptr will be created
225+
{
226+
std::lock_guard<std::mutex> reset_lock(_fs_cache_key_reset_mtx);
227+
auto fs = lookup_fs_cache(it->second.fs_cache_key);
228+
if (fs != nullptr) {
229+
return fs;
230+
}
231+
232+
it->second.fs_cache_key.reset();
227233
}
228234
shard_info = it->second.shard_info;
229235
}

be/src/service/staros_worker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class StarOSWorker : public staros::starlet::Worker {
138138
private:
139139
mutable std::shared_mutex _mtx;
140140
std::shared_mutex _cache_mtx;
141+
std::mutex _fs_cache_key_reset_mtx; // Protects fs_cache_key reset operations
141142
std::unordered_map<ShardId, ShardInfoDetails> _shards;
142143
std::unique_ptr<Cache> _fs_cache;
143144
add_shard_listener _add_shard_listener;

0 commit comments

Comments
 (0)