From bd63b8da0009075761535690e4fd9a270906b1f5 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Wed, 7 Sep 2016 11:31:17 +0100 Subject: [PATCH 1/1] Fsync all the things, all the time. --- .../files/default/replication-bin/replicate-changesets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cookbooks/planet/files/default/replication-bin/replicate-changesets b/cookbooks/planet/files/default/replication-bin/replicate-changesets index 74cd53caa..e71d4c548 100644 --- a/cookbooks/planet/files/default/replication-bin/replicate-changesets +++ b/cookbooks/planet/files/default/replication-bin/replicate-changesets @@ -225,6 +225,15 @@ class Replicator fh.write(YAML.dump(@state)) end + # fsync the files in their old locations. + fsync(tmp_data) + fsync(tmp_state) + + # sync the directory as well, to ensure that the file is reachable + # from the dirent and has been updated to account for any allocations. + fdirsync(File.dirname(tmp_data)) + fdirsync(File.dirname(tmp_state)) + # sanity check: the files we're moving into place # should be non-empty. raise "Temporary gzip file should exist, but doesn't." unless File.exist?(tmp_data) -- 2.43.2