{"record":{"id":"9408b391dc4b332e","repo":"spacejam/sled","slug":"failed-to-write-whole-buffer","errorCode":null,"errorMessage":"failed to write whole buffer","messagePattern":"failed to write whole buffer","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/heap.rs","lineNumber":482,"sourceCode":"        if !buf.is_empty() {\n            Err(annotate!(io::Error::new(\n                io::ErrorKind::UnexpectedEof,\n                \"failed to fill whole buffer\"\n            )))\n        } else {\n            Ok(())\n        }\n    }\n\n    pub(super) fn write_all_at(\n        file: &fs::File,\n        mut buf: &[u8],\n        mut offset: u64,\n    ) -> io::Result<()> {\n        while !buf.is_empty() {\n            match maybe!(file.seek_write(buf, offset)) {\n                Ok(0) => {\n                    return Err(annotate!(io::Error::new(\n                        io::ErrorKind::WriteZero,\n                        \"failed to write whole buffer\",\n                    )));\n                }\n                Ok(n) => {\n                    buf = &buf[n..];\n                    offset += n as u64;\n                }\n                Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}\n                Err(e) => return Err(annotate!(e)),\n            }\n        }\n        Ok(())\n    }\n}\n\n#[derive(Debug)]\nstruct Slab {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/spacejam/sled/blob/e449d17111f4a097e1c66b6db241962ccb6a4136/src/heap.rs#L464-L500","documentation":"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.","triggerScenarios":"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.","commonSituations":"Disk or quota full during heavy writes; writing after the file was closed elsewhere; faulty network filesystems or FUSE mounts returning zero writes.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check free space before heavy write sessions\nlet stat = nix::sys::statvfs::stat(path)?;\nif stat.blocks_available < min_free_blocks { return Err(anyhow!(\"disk almost full\")); }","typeGuard":null,"tryCatchPattern":"match Db::open(&path) {\n    Ok(db) => db,\n    Err(e) if e.kind() == std::io::ErrorKind::WriteZero => {\n        // free space / check fd validity, then reopen\n        free_disk_or_alert()?;\n        Db::open(&path)?\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["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"],"tags":["rust","io","write","storage"],"backgroundTag":"file-write-failed","analyzedSha":"e449d17111f4a097e1c66b6db241962ccb6a4136","analyzedAt":"2026-09-12T01:23:10.985Z","contentChangedAt":"2026-09-12T01:23:10.985Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}