{"record":{"id":"7913e8c71d5ff074","repo":"siyuan-note/siyuan","slug":"flush-data-s-failed-s","errorCode":null,"errorMessage":"flush data [%s] failed: %s","messagePattern":"flush data \\[(.+?)\\] failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/mmap.go","lineNumber":64,"sourceCode":"\t\tlogging.LogError(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\n\tm, err := mmap.Map(f, mmap.RDWR, 0)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"map file [%s] failed: %s\", filePath, err)\n\t\tlogging.LogError(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\tdefer m.Unmap()\n\n\tcopy(m, data)\n\tif err = m.Flush(); err != nil {\n\t\tmsg := fmt.Sprintf(\"flush data [%s] failed: %s\", filePath, err)\n\t\tlogging.LogError(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\treturn\n}\n","sourceCodeStart":46,"sourceCodeEnd":69,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/util/mmap.go#L46-L69","documentation":"After copying data into the memory map, WriteFileByMmap calls m.Flush() to push the mapping back to disk (msync). This error means the OS could not synchronize the mapped pages, so the on-disk file may not contain the written data even though the copy succeeded.","triggerScenarios":"Called via SaveAttributeView or WriteTree when msync fails — typically I/O errors on the underlying storage (disk full, failing disk, detached network mount) after mapping succeeded.","commonSituations":"Disk filled between truncate and flush; USB/network storage dropped mid-write; filesystem errors surfaced only at sync time.","solutions":["Read the wrapped OS error and run filesystem/disk diagnostics (dmesg, chkdsk)","Free disk space — flush fails with ENOSPC on full volumes","If the workspace is on a network/external drive, remount it or move the workspace to local storage","Retry the save; verify the file content on disk afterward since partial flushes are possible"],"exampleFix":"// before\n// save fails at flush on a full disk\n// after\n# free space on the workspace volume, then retry\ndf -h /path/to/workspace","handlingStrategy":"try-catch","validationCode":"// check free space before writing\nif st, err := os.Statfs(dir); err == nil && st.Bavail < 1024 { return errors.New(\"low disk\") }","typeGuard":null,"tryCatchPattern":"if err := util.WriteFileByMmap(path, data); err != nil {\n    log.Printf(\"flush failed, data may not be on disk: %v\", err)\n    // verify file content and retry; do not assume success\n}","preventionTips":["Monitor disk health and free space on the workspace volume","Avoid unreliable external/USB drives for workspaces","Verify written data after flush errors instead of trusting the file","Remount dropped network drives promptly"],"tags":["go","file-io","mmap","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}