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.

mount: avoid "send on closed channel"

Chris Lu09bab17affc5
diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go
index feaf8945bb..a200050c4f 100644
--- a/weed/filesys/dirty_page.go
+++ b/weed/filesys/dirty_page.go
@@ -10,13 +10,14 @@ import (
)
type ContinuousDirtyPages struct {
- intervals *ContinuousIntervals
- f *File
- writeWaitGroup sync.WaitGroup
- chunkSaveErrChan chan error
- lock sync.Mutex
- collection string
- replication string
+ intervals *ContinuousIntervals
+ f *File
+ writeWaitGroup sync.WaitGroup
+ chunkSaveErrChan chan error
+ chunkSaveErrChanClosed bool
+ lock sync.Mutex
+ collection string
+ replication string
}
func newDirtyPages(file *File) *ContinuousDirtyPages {
@@ -82,6 +83,11 @@ func (pages *ContinuousDirtyPages) saveExistingLargestPageToStorage() (hasSavedD
func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, size int64) {
+ if pages.chunkSaveErrChanClosed {
+ pages.chunkSaveErrChan = make(chan error, 8)
+ pages.chunkSaveErrChanClosed = false
+ }
+
mtime := time.Now().UnixNano()
pages.writeWaitGroup.Add(1)
go func() {
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 687588788f..01bca76f86 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -186,6 +186,7 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
}
// stop the goroutine
+ fh.dirtyPages.chunkSaveErrChanClosed = true
close(fh.dirtyPages.chunkSaveErrChan)
return nil