]> git.openstreetmap.org Git - chef.git/commitdiff
Fsync all the things, all the time.
authorMatt Amos <zerebubuth@gmail.com>
Wed, 7 Sep 2016 10:31:17 +0000 (11:31 +0100)
committerMatt Amos <zerebubuth@gmail.com>
Wed, 7 Sep 2016 10:31:17 +0000 (11:31 +0100)
cookbooks/planet/files/default/replication-bin/replicate-changesets

index 74cd53caad6e10266f5190a96382262e37894828..e71d4c5482aae3a861f250de6ddde77accafc870 100644 (file)
@@ -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)