spacejam/sled · critical
failed to write whole buffer
Error message
failed to write whole buffer
What it means
write_all_at retries pwrite-like writes until the whole buffer is flushed; if the underlying write returns 0 bytes written, progress is impossible, so it returns WriteZero with this message. It indicates the storage layer accepted the call but wrote nothing.
Solutions
- Free disk space or raise quota, then retry the operation
- Check application logs for errors on the file handle; reopen the database if the fd went bad
- Check the storage mount health (dmesg, filesystem errors) and replace failing media
- Ensure no other code path closes the database file concurrently
Defensive patterns
Strategy: retry
Validate before calling
// check free space before heavy write sessions
let stat = nix::sys::statvfs::stat(path)?;
if stat.blocks_available < min_free_blocks { return Err(anyhow!("disk almost full")); } Try / catch
match Db::open(&path) {
Ok(db) => db,
Err(e) if e.kind() == std::io::ErrorKind::WriteZero => {
// free space / check fd validity, then reopen
free_disk_or_alert()?;
Db::open(&path)?
}
Err(e) => return Err(e.into()),
} Prevention
- Alert on disk usage thresholds before writes start failing
- Avoid closing the database file while other handles are in use
- Prefer local filesystems over flaky network mounts for database storage
- Watch kernel logs for I/O errors on the backing device
When it happens
Trigger: A seek_write to the file returns Ok(0): typically a full disk, a closed/invalid file descriptor, quota exhaustion, or an I/O layer bug that reports zero-length writes.
Common situations: Disk or quota full during heavy writes; writing after the file was closed elsewhere; faulty network filesystems or FUSE mounts returning zero writes.
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
- failed to fill whole buffer
- encountered corrupted settings cookie with mismatched CRC.
- crc mismatch - data corruption detected
- Db's LEAF_FANOUT const generic must be 3 or greater.
- encountered unknown version number when reading settings…
AI-assisted analysis of spacejam/sled@e449d17111 (2026-09-12).
Data as JSON: /api/errors/9408b391dc4b332e.
Report an issue: GitHub.
Appendix: source
Thrown at src/heap.rs:482
if !buf.is_empty() {
Err(annotate!(io::Error::new(
io::ErrorKind::UnexpectedEof,
"failed to fill whole buffer"
)))
} else {
Ok(())
}
}
pub(super) fn write_all_at(
file: &fs::File,
mut buf: &[u8],
mut offset: u64,
) -> io::Result<()> {
while !buf.is_empty() {
match maybe!(file.seek_write(buf, offset)) {
Ok(0) => {
return Err(annotate!(io::Error::new(
io::ErrorKind::WriteZero,
"failed to write whole buffer",
)));
}
Ok(n) => {
buf = &buf[n..];
offset += n as u64;
}
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
Err(e) => return Err(annotate!(e)),
}
}
Ok(())
}
}
#[derive(Debug)]
struct Slab {View on GitHub (pinned to e449d17111)