Skip to main content

sync_directory_after_publish

Function sync_directory_after_publish 

Source
pub(crate) fn sync_directory_after_publish(dir: &Path) -> bool
Expand description

Fsyncs the directory of a file that has just been renamed into place.

A failure is logged and otherwise ignored. By the time this runs the file’s contents, footer included, have been fsynced and the rename has succeeded, so readers already see a complete .parquet file. Reporting the close as failed at this point would leave its messages unacked, and JetStream would redeliver them into a second file, duplicating every sample in the archive. Treating it as a success risks less: the rename can only be lost if power fails before the filesystem commits it on its own (a few seconds on ext4), and even then the complete file survives under its .inprogress name and is kept by quarantine_incomplete_files rather than deleted.

§Arguments

  • dir - Directory holding the published file.

§Returns

true if the directory was synced, false if opening or syncing it failed.