Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

disable async file deletion

Chris Lubd32108a90b3
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go
index f8b9a049cd..fae2892177 100644
--- a/weed/filesys/dir.go
+++ b/weed/filesys/dir.go
@@ -329,7 +329,7 @@ func (dir *Dir) removeOneFile(ctx context.Context, req *fuse.RemoveRequest) erro
return err
}
- dir.wfs.asyncDeleteFileChunks(entry.Chunks)
+ dir.wfs.deleteFileChunks(entry.Chunks)
return dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 23741a0520..0f6ca1164e 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -220,7 +220,7 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
chunks, garbages := filer2.CompactFileChunks(fh.f.entry.Chunks)
fh.f.entry.Chunks = chunks
// fh.f.entryViewCache = nil
- fh.f.wfs.asyncDeleteFileChunks(garbages)
+ fh.f.wfs.deleteFileChunks(garbages)
if _, err := client.CreateEntry(ctx, request); err != nil {
return fmt.Errorf("update fh: %v", err)
diff --git a/weed/filesys/wfs_deletion.go b/weed/filesys/wfs_deletion.go
index 45eb683971..f58ef24f45 100644
--- a/weed/filesys/wfs_deletion.go
+++ b/weed/filesys/wfs_deletion.go
@@ -35,12 +35,24 @@ func (wfs *WFS) loopProcessingDeletion() {
}
-func (wfs *WFS) asyncDeleteFileChunks(chunks []*filer_pb.FileChunk) {
- if len(chunks) > 0 {
- var fileIds []string
- for _, chunk := range chunks {
- fileIds = append(fileIds, chunk.FileId)
- }
+func (wfs *WFS) deleteFileChunks(chunks []*filer_pb.FileChunk) {
+ if len(chunks) == 0 {
+ return
+ }
+
+ var fileIds []string
+ for _, chunk := range chunks {
+ fileIds = append(fileIds, chunk.FileId)
+ }
+
+ var async = false
+ if async {
wfs.fileIdsDeletionChan <- fileIds
+ return
}
+
+ wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
+ deleteFileIds(context.Background(), client, fileIds)
+ return nil
+ })
}