{"record":{"id":"6525fb3e767f8ce1","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-fsync-directory","errorCode":null,"errorMessage":"failed to fsync directory {}: {}","messagePattern":"failed to fsync directory (.+?): (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/snapshot/src/lib.rs","lineNumber":1587,"sourceCode":"    /// On *nix systems, both a file and its enclosing directory should be\n    /// `fsync`ed to make the file durable.\n    ///\n    /// On Windows, only the file needs to be synced, and it's even an error to\n    /// sync a directory. Passing in [Self::Dir] is thus a no-op on Windows.\n    fn sync_all(&self) -> io::Result<()> {\n        match self {\n            #[cfg(target_os = \"windows\")]\n            Self::Dir(path) => Ok(()),\n            #[cfg(not(target_os = \"windows\"))]\n            Self::Dir(path) => File::open(path)\n                .map_err(|e| {\n                    io::Error::new(\n                        e.kind(),\n                        format!(\"failed to open directory {} for fsync: {}\", path.display(), e),\n                    )\n                })?\n                .sync_all()\n                .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)))","sourceCodeStart":1569,"sourceCodeEnd":1605,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/snapshot/src/lib.rs#L1569-L1605","documentation":"Same durability sync: the snapshot directory opened successfully, but the sync_all syscall on it failed. This is a low-level I/O error from the filesystem or device while flushing directory metadata; the snapshot's directory entries are not guaranteed crash-durable.","triggerScenarios":"Dir(path).sync_all() returning an error: device or filesystem failure, network filesystems that do not support directory fsync, or ENOSPC-like conditions at flush time.","commonSituations":"Snapshot storage placed on NFS/SMB or exotic filesystems; failing disks; volumes that run full under heavy write load.","solutions":["Move snapshot storage to a local POSIX filesystem.","Check disk health and free space.","Re-run the snapshot; treat the previous attempt as not durable."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match sync_result {\n    Err(e) if e.to_string().contains(\"failed to fsync directory\") => {\n        // Low-level durability failure: check disk/filesystem, then re-run the\n        // snapshot from scratch; the previous attempt is not durable.\n    }\n    r => r,\n}","preventionTips":["Keep snapshot storage on a local POSIX filesystem, not NFS/SMB.","Monitor disk health and free space.","Treat any fsync failure as making the snapshot invalid, never serve from it."],"tags":["snapshot","fsync","filesystem","rust"],"backgroundTag":"fsync-failure","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}