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.

ensure releasing file handle

chrislu3aeee3d74871
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go
index 770e89a109..86fbabfa71 100644
--- a/weed/mount/filehandle.go
+++ b/weed/mount/filehandle.go
@@ -88,6 +88,10 @@ func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
fh.chunkAddLock.Unlock()
}
+func (fh *FileHandle) Release() {
+ fh.dirtyPages.Destroy()
+}
+
func lessThan(a, b *filer_pb.FileChunk) bool {
if a.Mtime == b.Mtime {
return a.Fid.FileKey < b.Fid.FileKey
diff --git a/weed/mount/filehandle_map.go b/weed/mount/filehandle_map.go
index 80cfd02c74..a8af391afc 100644
--- a/weed/mount/filehandle_map.go
+++ b/weed/mount/filehandle_map.go
@@ -61,6 +61,7 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
if fh.counter <= 0 {
delete(i.inode2fh, inode)
delete(i.fh2inode, fh.fh)
+ fh.Release()
}
}
}
@@ -77,6 +78,7 @@ func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
if fhHandle.counter <= 0 {
delete(i.inode2fh, inode)
delete(i.fh2inode, fhHandle.fh)
+ fhHandle.Release()
}
}
diff --git a/weed/mount/page_writer/upload_pipeline.go b/weed/mount/page_writer/upload_pipeline.go
index e439f39a30..3ed966de41 100644
--- a/weed/mount/page_writer/upload_pipeline.go
+++ b/weed/mount/page_writer/upload_pipeline.go
@@ -179,4 +179,7 @@ func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex Logic
}
func (up *UploadPipeline) Shutdown() {
+ for logicChunkIndex, sealedChunk := range up.sealedChunks {
+ sealedChunk.FreeReference(fmt.Sprintf("%s uploadpipeline shutdown chunk %d", up.filepath, logicChunkIndex))
+ }
}