{"record":{"id":"d812e1148e55c26e","repo":"RyanCodrai/turbovec","slug":"path-was-written-and-committed-but-syncing-its","errorCode":null,"errorMessage":"{path} was written and committed, but syncing its parent directory failed ({e}); the file is visible now but the rename may not survive power loss","messagePattern":"(.+?) was written and committed, but syncing its parent directory failed \\((.+?)\\); the file is visible now but the rename may not survive power loss","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"turbovec/src/io.rs","lineNumber":495,"sourceCode":"    Ok(())\n}\n\n/// Run the post-rename parent-directory fsync, which cannot fail the save.\n///\n/// The rename is the commit point: once it returns, the new file is the\n/// one readers see and the temp name is gone. A failure of the directory\n/// fsync *after* that point is a durability shortfall on an\n/// already-committed file, not a failed save — reporting it as `Err`\n/// would tell a caller its previous file is still in place when it is\n/// not, sending retry/rollback policies down a destructive path, and the\n/// error cleanup would then try to unlink a temp name that no longer\n/// exists (#365). So the save succeeds and the shortfall is reported as\n/// a non-fatal diagnostic through [`crate::warning`], which an embedder\n/// can route into its own logging (or silence) instead of being handed\n/// an unconditional line on stderr.\npub(crate) fn sync_parent_dir_after_commit(path: &Path) {\n    if let Err(e) = sync_parent_dir(path) {\n        crate::warning::warn(&format!(\n            \"{} was written and committed, but syncing its parent directory \\\n             failed ({e}); the file is visible now but the rename may not \\\n             survive power loss\",\n            path.display(),\n        ));\n    }\n}\n\n\n\n\n\n\n\n\n\n\n","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec/src/io.rs#L477-L513","documentation":"After committing an index file, sync_parent_dir_after_commit calls sync_parent_dir to fsync the containing directory so the rename/new file survives power loss; this is unsupported or failing on some platforms/filesystems (issue #365). The failure is reported as a non-fatal warning via crate::warning rather than an error — the data is written and visible, only durability of the directory entry is in question.","triggerScenarios":"Saving/committing an index on a filesystem or platform where fsync on a directory fd fails (e.g. some Windows or network filesystems), during any save/sync commit path.","commonSituations":"Saving to network mounts (NFS/SMB), unusual container filesystems, or Windows where directory fsync is unavailable.","solutions":["Treat it as a diagnostic: the file was written; verify durability requirements per platform","Save to a local filesystem that supports directory fsync","Silence/route the warning via the crate::warning hook if durability is handled elsewhere (e.g. snapshotting FS)","Copy the file and re-save after confirming the parent dir is syncable"],"exampleFix":"// before\nidx.save(\"/mnt/nfs/index.tv\")?; // warns: parent dir sync failed\n// after\ncrate::warning::set_handler(|w| log::debug!(\"{}\", w)); // or:\nidx.save(\"/var/lib/app/index.tv\")?; // local fs, dir fsync works","handlingStrategy":"try-catch","validationCode":"# ensure the destination filesystem supports directory fsync before saving\nimport os\nif os.statvfs(save_path).f_bsize and save_path.startswith((\"/mnt/\", \"/net/\")):\n    logging.warning(\"saving to network fs; parent-dir sync may fail\")","typeGuard":"def is_local_fs(path: str) -> bool:\n    import os\n    return not path.startswith((\"/mnt/\", \"/net/\", \"//\"))  # rough heuristic\n# guard: is_local_fs(save_path) before idx.save(save_path)","tryCatchPattern":"import warnings\nwith warnings.catch_warnings(record=True) as caught:\n    idx.save(path)\ndurability_warnings = [w for w in caught if \"parent directory\" in str(w.message)]\nif durability_warnings:\n    logging.warning(\"file written but directory fsync failed: %s\", durability_warnings)","preventionTips":["Save indexes to local filesystems that support directory fsync","Route crate/warning diagnostics into structured logs","Do not treat this warning as save failure — the file was committed"],"tags":["io","durability","fsync","warning"],"backgroundTag":"file-write-failed","analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}