{"record":{"id":"77a715d535a98c48","repo":"influxdata/influxdb","slug":"wal-file-too-small-expected-at-least-expected-bytes-but-got","errorCode":null,"errorMessage":"WAL file too small: expected at least {expected} bytes, but got {actual} bytes","messagePattern":"WAL file too small: expected at least (.+?) bytes, but got (.+?) bytes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_wal/src/serialize.rs","lineNumber":17,"sourceCode":"//! Module for serializing and deserializing the contents of a single WAL file. Since the WAL is\n//! buffered in memory before writing it in a single PUT operation to object store, this works\n//! a little differently than a traditional WAL that appends.\n\nuse crate::WalContents;\nuse byteorder::{BigEndian, ReadBytesExt};\nuse bytes::Bytes;\nuse std::io::Cursor;\nuse std::mem::size_of;\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum Error {\n    #[error(\"Invalid wal file identifier\")]\n    InvalidWalFile,\n\n    #[error(\"WAL file too small: expected at least {expected} bytes, but got {actual} bytes\")]\n    WalFileTooSmall { expected: usize, actual: usize },\n\n    #[error(\"crc32 checksum mismatch\")]\n    Crc32Mismatch,\n\n    #[error(\"bitcode error: {0}\")]\n    Bitcode(#[from] bitcode::Error),\n\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"try from slice error {0}\")]\n    TryFromSlice(#[from] std::array::TryFromSliceError),\n}\n\npub(crate) type Result<T, E = Error> = std::result::Result<T, E>;\n\n/// The first bytes written into a wal file to identify it and its version.","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_wal/src/serialize.rs#L1-L35","documentation":"serialize::Error::WalFileTooSmall is thrown when a WAL file has fewer bytes than the minimum required to hold the header (magic identifier + size fields), with the expected and actual byte counts in the message. The reader needs at least the fixed-size identifier block before it can even validate the file; anything smaller cannot be a valid WAL file.","triggerScenarios":"verify_file_type_and_deserialize reads a file whose length is below the required minimum header size (serialize.rs:48-60, error constructed around lines 86-98); this happens on zero-length files created by crashes mid-create, and on files truncated below the header size.","commonSituations":"Disk-full conditions leaving an empty .wal file; a process killed between file creation and first write; rsync/backup tooling copying partial files; manual truncation with head/echo during debugging.","solutions":["Delete or quarantine the too-small WAL file — it contains no recoverable segment data; the WAL will resume from valid files.","Restore the file from a backup if the data matters.","Fix the underlying disk-space or crash condition so new files are fully written.","Add monitoring for zero-length WAL files after unclean shutdowns so they are cleaned before readers trip on them."],"exampleFix":"# before: crash-left empty file blocks replay\nls wal/1/1712345678/0000000007.wal  # 0 bytes -> WalFileTooSmall { expected: N, actual: 0 }\n# after: remove the empty file, restart\nrm wal/1/1712345678/0000000007.wal","handlingStrategy":"validation","validationCode":"// pre-check file size against the header minimum before deserializing\nlet meta = std::fs::metadata(path)?;\nif meta.len() < MIN_HEADER_SIZE as u64 {\n    // too small to be a WAL file: quarantine/delete\n}","typeGuard":"fn is_plausible_wal(path: &Path) -> bool {\n    std::fs::metadata(path).map(|m| m.len() >= MIN_HEADER_SIZE as u64).unwrap_or(false)\n}","tryCatchPattern":"match verify_file_type_and_deserialize(&bytes) {\n    Err(serialize::Error::WalFileTooSmall { expected, actual }) => {\n        // zero/short file from crash: remove and continue replay\n    }\n    other => other?,\n}","preventionTips":["Monitor disk space so writes are never cut short.","After unclean shutdowns, sweep for zero-length .wal files and delete them.","Restore files from backups with size verification."],"tags":["rust","wal","serialization","truncation","corruption"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}