RyanCodrai/turbovec · warning
{path} was written and committed, but syncing its parent dir
Error message
{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 What it means
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.
Source
Thrown at turbovec/src/io.rs:495
Ok(())
}
/// Run the post-rename parent-directory fsync, which cannot fail the save.
///
/// The rename is the commit point: once it returns, the new file is the
/// one readers see and the temp name is gone. A failure of the directory
/// fsync *after* that point is a durability shortfall on an
/// already-committed file, not a failed save — reporting it as `Err`
/// would tell a caller its previous file is still in place when it is
/// not, sending retry/rollback policies down a destructive path, and the
/// error cleanup would then try to unlink a temp name that no longer
/// exists (#365). So the save succeeds and the shortfall is reported as
/// a non-fatal diagnostic through [`crate::warning`], which an embedder
/// can route into its own logging (or silence) instead of being handed
/// an unconditional line on stderr.
pub(crate) fn sync_parent_dir_after_commit(path: &Path) {
if let Err(e) = sync_parent_dir(path) {
crate::warning::warn(&format!(
"{} was written and committed, but syncing its parent directory \
failed ({e}); the file is visible now but the rename may not \
survive power loss",
path.display(),
));
}
}
View on GitHub (pinned to ccab9f325e)
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
Example fix
// before
idx.save("/mnt/nfs/index.tv")?; // warns: parent dir sync failed
// after
crate::warning::set_handler(|w| log::debug!("{}", w)); // or:
idx.save("/var/lib/app/index.tv")?; // local fs, dir fsync works Defensive patterns
Strategy: try-catch
Validate before calling
# ensure the destination filesystem supports directory fsync before saving
import os
if os.statvfs(save_path).f_bsize and save_path.startswith(("/mnt/", "/net/")):
logging.warning("saving to network fs; parent-dir sync may fail") Type guard
def is_local_fs(path: str) -> bool:
import os
return not path.startswith(("/mnt/", "/net/", "//")) # rough heuristic
# guard: is_local_fs(save_path) before idx.save(save_path) Try / catch
import warnings
with warnings.catch_warnings(record=True) as caught:
idx.save(path)
durability_warnings = [w for w in caught if "parent directory" in str(w.message)]
if durability_warnings:
logging.warning("file written but directory fsync failed: %s", durability_warnings) Prevention
- 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
When it happens
Trigger: 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.
Common situations: Saving to network mounts (NFS/SMB), unusual container filesystems, or Windows where directory fsync is unavailable.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- {src}: the newest commit (generation {newest}) is incomplete
- {} {detail}.
- truncated file
- file too large for this platform
- similarity='dot_product' produces unbounded raw inner produc
AI-assisted analysis of RyanCodrai/turbovec@ccab9f325e (2026-09-06).
Data as JSON: /api/errors/d812e1148e55c26e.
Report an issue: GitHub.