{"record":{"id":"89aad2c97b0c2d86","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-fsync-file","errorCode":null,"errorMessage":"failed to fsync file {}: {}","messagePattern":"failed to fsync file (.+?): (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/snapshot/src/lib.rs","lineNumber":1605,"sourceCode":"                .map_err(|e| io::Error::new(e.kind(), format!(\"failed to fsync directory {}: {}\", path.display(), e))),\n            Self::File(path) => {\n                File::options()\n                    .read(true)\n                    // Windows needs the file to be writable for `sync_all` to work.\n                    // Set all the open options explicitly, just for visibility.\n                    .write(true)\n                    .truncate(false)\n                    .create(false)\n                    .append(false)\n                    .open(path)\n                    .map_err(|e| {\n                        io::Error::new(\n                            e.kind(),\n                            format!(\"failed to open file {} for fsync: {}\", path.display(), e),\n                        )\n                    })?\n                    .sync_all()\n                    .map_err(|e| io::Error::new(e.kind(), format!(\"failed to fsync file {}: {}\", path.display(), e)))\n            }\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::fs::OpenOptions;\n\n    use tempfile::tempdir;\n\n    use super::*;\n\n    #[test]\n    fn listing_ignores_if_snapshot_file_is_missing() -> anyhow::Result<()> {\n        let tmp = tempdir()?;\n\n        let root = SnapshotsPath::from_path_unchecked(tmp.path());","sourceCodeStart":1587,"sourceCodeEnd":1623,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/snapshot/src/lib.rs#L1587-L1623","documentation":"The final durability step for a snapshot file: the file opened fine, but sync_all() on it returned an error. The file's data was not flushed to stable storage, so the snapshot must be treated as potentially incomplete after a crash.","triggerScenarios":"Device-level I/O errors during fsync; ENOSPC surfacing at flush time on write-back filesystems (ext4 delayed allocation); virtualized storage with unreliable flush semantics.","commonSituations":"Disks failing under fsync load; disk full at flush time; thin-provisioned network volumes that acknowledge writes before they are durable.","solutions":["Check disk health and free space immediately.","Re-run the snapshot and do not trust the un-synced file.","Use storage with reliable flush semantics (local SSD rather than thin-provisioned network volumes)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match sync_result {\n    Err(e) if e.to_string().contains(\"failed to fsync file\") => {\n        // Device-level flush failure: check disk health/space, discard the snapshot,\n        // and retry once storage is stable.\n    }\n    r => r,\n}","preventionTips":["Monitor disk health and free space; fsync failures usually precede disk failure.","Use storage with reliable flush semantics.","Never promote a snapshot whose fsync failed."],"tags":["snapshot","fsync","disk-io","rust"],"backgroundTag":"fsync-failure","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}