From 5ce378b046e500eadd1fb53e1b1488488488ce1f Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Sat, 22 Mar 2014 20:45:53 -0700 Subject: Call fdatasync/fsync after writing out non-meta pages This avoids a case where writes can be reordered so meta page is written before a page it refers to, potentially causing a corrupt database after a power loss or kernel crash. --- sync_linux.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 sync_linux.go (limited to 'sync_linux.go') diff --git a/sync_linux.go b/sync_linux.go new file mode 100644 index 0000000..351b65a --- /dev/null +++ b/sync_linux.go @@ -0,0 +1,10 @@ +package bolt + +import ( + "os" + "syscall" +) + +func fdatasync(f *os.File) error { + return syscall.Fdatasync(int(f.Fd())) +} -- cgit v1.2.3