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 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-04 01:49:17 -08:00
1 parent e6f084bbaf
commit f2b1963087
1 file changed
+5 -5
+5 -5
View File
@@ -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()
}