fix(ecstore): invalidate GlobalFileCache after write_all_private to fix DeleteMarker visibility (#1890)

This commit is contained in:
loverustfs
2026-02-20 22:47:45 +08:00
committed by GitHub
parent cde66e0a46
commit 5d737eaeb7
3 changed files with 305 additions and 1 deletions
+13 -1
View File
@@ -894,7 +894,13 @@ impl LocalDisk {
check_path_length(file_path.to_string_lossy().as_ref())?;
self.write_all_internal(&file_path, InternalBuf::Owned(buf), sync, skip_parent)
.await
.await?;
// Invalidate file cache after successful write to ensure listing and other readers
// see the updated metadata immediately (e.g. delete markers created via delete_objects).
get_global_file_cache().invalidate(&file_path).await;
Ok(())
}
// write_all_internal do write file
async fn write_all_internal(&self, file_path: &Path, data: InternalBuf<'_>, sync: bool, skip_parent: &Path) -> Result<()> {
@@ -2164,6 +2170,12 @@ impl DiskAPI for LocalDisk {
return Err(err);
}
// Invalidate cache entries for both source and destination xl.meta so that reads
// after rename_data (e.g. immediately after put_object) see the new version rather
// than stale cached data, and cannot obtain data via the old source path.
get_global_file_cache().invalidate(&src_file_path).await;
get_global_file_cache().invalidate(&dst_file_path).await;
if let Some(src_file_path_parent) = src_file_path.parent() {
if src_volume != super::RUSTFS_META_MULTIPART_BUCKET {
let _ = remove_std(src_file_path_parent);