siyuan-note/siyuan · error

flush data [%s] failed: %s

Error message

flush data [%s] failed: %s

What it means

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.

Source

Thrown at kernel/util/mmap.go:64

		logging.LogError(msg)
		err = errors.New(msg)
		return
	}

	m, err := mmap.Map(f, mmap.RDWR, 0)
	if err != nil {
		msg := fmt.Sprintf("map file [%s] failed: %s", filePath, err)
		logging.LogError(msg)
		err = errors.New(msg)
		return
	}
	defer m.Unmap()

	copy(m, data)
	if err = m.Flush(); err != nil {
		msg := fmt.Sprintf("flush data [%s] failed: %s", filePath, err)
		logging.LogError(msg)
		err = errors.New(msg)
		return
	}
	return
}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Read the wrapped OS error and run filesystem/disk diagnostics (dmesg, chkdsk)
  2. Free disk space — flush fails with ENOSPC on full volumes
  3. If the workspace is on a network/external drive, remount it or move the workspace to local storage
  4. Retry the save; verify the file content on disk afterward since partial flushes are possible

Example fix

// before
// save fails at flush on a full disk
// after
# free space on the workspace volume, then retry
df -h /path/to/workspace
Defensive patterns

Strategy: try-catch

Validate before calling

// check free space before writing
if st, err := os.Statfs(dir); err == nil && st.Bavail < 1024 { return errors.New("low disk") }

Try / catch

if err := util.WriteFileByMmap(path, data); err != nil {
    log.Printf("flush failed, data may not be on disk: %v", err)
    // verify file content and retry; do not assume success
}

Prevention

When it happens

Trigger: 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.

Common situations: Disk filled between truncate and flush; USB/network storage dropped mid-write; filesystem errors surfaced only at sync time.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/7913e8c71d5ff074. Report an issue: GitHub.