From e6f084bbaf72ab9dc6b72ef36c8431214873cd20 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 4 Dec 2026 01:31:42 -0800 Subject: [PATCH] mount: leave the meta cache open when the shutdown flush times out A flush still running after the 30s bound holds its handle's lock. Closing the meta cache drains queued invalidations, and one for that handle waits on the same lock, so the hook blocked past its bound until the flush gave up. Skip the close in that case, as the write cache removal already is; the process exits right after the hooks. Co-Authored-By: Claude Opus 5.5 --- weed/mount/weedfs.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.go index ed902d0ea8..0d29aab387 100644 --- a/weed/mount/weedfs.go +++ b/weed/mount/weedfs.go @@ -394,7 +394,9 @@ 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. + // 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 @@ -415,8 +417,8 @@ func NewSeaweedFileSystem(option *Option) *WFS { } // End the metadata follow before closing the cache it writes into. wfs.stopMetadataFollow() - wfs.metaCache.Shutdown() if asyncDrained { + wfs.metaCache.Shutdown() os.RemoveAll(option.getUniqueCacheDirForWrite()) } os.RemoveAll(option.getUniqueCacheDirForRead())