Skip to content

Commit b5f6d4e

Browse files
[BugFix]Fix filesystem cache failure. (backport #65823) (#65980)
Signed-off-by: edwinhzhang <[email protected]> Signed-off-by: edwinhzhang <[email protected]> Co-authored-by: zhanghe <[email protected]>
1 parent ed0e480 commit b5f6d4e

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
@@ -184,9 +184,15 @@ absl::StatusOr<std::shared_ptr<fslib::FileSystem>> StarOSWorker::get_shard_files
184184
return build_filesystem_on_demand(id, conf);
185185
}
186186

187-
auto fs = lookup_fs_cache(it->second.fs_cache_key);
188-
if (fs != nullptr) {
189-
return fs;
187+
// Cache miss: reset the fs_cache_key to ensure a new shared_ptr will be created
188+
{
189+
std::lock_guard<std::mutex> reset_lock(_fs_cache_key_reset_mtx);
190+
auto fs = lookup_fs_cache(it->second.fs_cache_key);
191+
if (fs != nullptr) {
192+
return fs;
193+
}
194+
195+
it->second.fs_cache_key.reset();
190196
}
191197
shard_info = it->second.shard_info;
192198
}

be/src/service/staros_worker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class StarOSWorker : public staros::starlet::Worker {
121121
private:
122122
mutable std::shared_mutex _mtx;
123123
std::shared_mutex _cache_mtx;
124+
std::mutex _fs_cache_key_reset_mtx; // Protects fs_cache_key reset operations
124125
std::unordered_map<ShardId, ShardInfoDetails> _shards;
125126
std::unique_ptr<Cache> _fs_cache;
126127
};

0 commit comments

Comments
 (0)