From f2b19630877cef74fd6fcb1e7f7d82a908959ca4 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 4 Dec 2026 01:49:17 -0800 Subject: [PATCH] mount: keep the read cache dir when the shutdown flush times out By default the write cache lives inside the read cache dir, so removing the read cache on the timeout path deleted the swap files that the still running flushes read, along with the meta store left open for them. Remove both dirs only after the flushes drain. The meta store is recreated on the next start. Co-Authored-By: Claude Opus 5.5 --- weed/mount/weedfs.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.go index 0d29aab387..895696daab 100644 --- a/weed/mount/weedfs.go +++ b/weed/mount/weedfs.go @@ -393,10 +393,10 @@ func NewSeaweedFileSystem(option *Option) *WFS { // // Use a timeout to avoid hanging on Ctrl-C if the filer is // unreachable: writeback flushes retry until it answers. - // If the timeout expires, skip the write-cache removal so that - // still-running goroutines can finish reading swap files, and leave - // the meta cache open: its invalidations wait for the handle locks - // those flushes hold. + // If the timeout expires, keep the cache dirs, which by default + // hold the write cache, so that still-running goroutines can finish + // reading swap files, and leave the meta cache open: its + // invalidations wait for the handle locks those flushes hold. // Open files are flushed first: their buffered writes would otherwise // die with the process. asyncDrained := true @@ -420,8 +420,8 @@ func NewSeaweedFileSystem(option *Option) *WFS { if asyncDrained { wfs.metaCache.Shutdown() os.RemoveAll(option.getUniqueCacheDirForWrite()) + os.RemoveAll(option.getUniqueCacheDirForRead()) } - os.RemoveAll(option.getUniqueCacheDirForRead()) if wfs.accessReporter != nil { wfs.accessReporter.stop() }