aboutsummaryrefslogtreecommitdiff
path: root/weed/command/mount.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-12-10 12:45:04 -0800
committerGitHub <noreply@github.com>2025-12-10 12:45:04 -0800
commit4c36cd04d6e7a16d468729bd0299c4a947c4b103 (patch)
tree496bb01fdc674a2c93559536a96602278ee642d0 /weed/command/mount.go
parent27a28faf49473c43a30fc90babf34c946f1b8b18 (diff)
downloadseaweedfs-4c36cd04d6e7a16d468729bd0299c4a947c4b103.tar.xz
seaweedfs-4c36cd04d6e7a16d468729bd0299c4a947c4b103.zip
mount: add periodic metadata sync to protect chunks from orphan cleanup (#7700)
mount: add periodic metadata flush to protect chunks from orphan cleanup When a file is opened via FUSE mount and written for a long time without being closed, chunks are uploaded to volume servers but the file metadata (containing chunk references) is only saved to the filer on file close. If volume.fsck runs during this window, it may identify these chunks as orphans (not referenced in filer metadata) and purge them, causing data loss. This commit adds a background task that periodically flushes file metadata for open files to the filer, ensuring chunk references are visible to volume.fsck even before files are closed. New option: -metadataFlushSeconds (default: 120) Interval in seconds for flushing dirty file metadata to filer. Set to 0 to disable. Fixes: https://github.com/seaweedfs/seaweedfs/issues/7649
Diffstat (limited to 'weed/command/mount.go')
-rw-r--r--weed/command/mount.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/weed/command/mount.go b/weed/command/mount.go
index 618bbd3ae..11e6e4c7c 100644
--- a/weed/command/mount.go
+++ b/weed/command/mount.go
@@ -37,6 +37,9 @@ type MountOptions struct {
extraOptions []string
fuseCommandPid int
+ // Periodic metadata flush to protect against orphan chunk cleanup
+ metadataFlushSeconds *int
+
// RDMA acceleration options
rdmaEnabled *bool
rdmaSidecarAddr *string
@@ -85,6 +88,9 @@ func init() {
mountOptions.disableXAttr = cmdMount.Flag.Bool("disableXAttr", false, "disable xattr")
mountOptions.fuseCommandPid = 0
+ // Periodic metadata flush to protect against orphan chunk cleanup
+ mountOptions.metadataFlushSeconds = cmdMount.Flag.Int("metadataFlushSeconds", 120, "periodically flush file metadata to filer in seconds (0 to disable). This protects chunks from being purged by volume.fsck for long-running writes")
+
// RDMA acceleration flags
mountOptions.rdmaEnabled = cmdMount.Flag.Bool("rdma.enabled", false, "enable RDMA acceleration for reads")
mountOptions.rdmaSidecarAddr = cmdMount.Flag.String("rdma.sidecar", "", "RDMA sidecar address (e.g., localhost:8081)")