From fde5a60549a735adecd5a3297d077b5deb3694ad Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 1 Jul 2016 01:11:12 +0200 Subject: [PATCH] make sure data hits disk before commit tag, fixes #1236 --- borg/repository.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/borg/repository.py b/borg/repository.py index 239fd1965..67e4b1f27 100644 --- a/borg/repository.py +++ b/borg/repository.py @@ -727,8 +727,11 @@ def write_commit(self): fd = self.get_write_fd(no_new=True) header = self.header_no_crc_fmt.pack(self.header_fmt.size, TAG_COMMIT) crc = self.crc_fmt.pack(crc32(header) & 0xffffffff) + # first fsync(fd) here (to ensure data supposedly hits the disk before the commit tag) + fd.flush() + os.fsync(fd.fileno()) fd.write(b''.join((crc, header))) - self.close_segment() + self.close_segment() # after-commit fsync() def close_segment(self): if self._write_fd: