treedirstate: sync all data and metadata when flushing

Summary:
When appending to the dirstate tree file, treedirstate flushes all data, and
then calls `sync_data` to ensure the data has made it to the disk.  This ought
to be sufficient, as the data won't be used until the dirstate file has been
updated to include the new root, which happens via atomic rename later on.

We've seen some cases where the dirstate file contains an invalid root id.
Attempt to mitigate this by syncing all data when we flush the dirstate.  There
is a performance penalty to this, but it shouldn't be too much.

Differential Revision: D7599547

fbshipit-source-id: 9d55b80d04833d2a73f058487a62eab2da802214
This commit is contained in:
Mark Thomas 2018-04-12 08:13:41 -07:00 committed by Saurabh Singh
parent e846e43ff2
commit b6bdd61b72

View File

@ -154,7 +154,7 @@ impl Store for FileStore {
fn flush(&mut self) -> Result<()> {
let file = self.file.get_mut();
file.flush()?;
file.get_mut().sync_data()?;
file.get_mut().sync_all()?;
Ok(())
}
}