diff --git a/util/env_posix.cc b/util/env_posix.cc index bce9526a63..9e76a126dc 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -761,6 +761,10 @@ class PosixWritableFile : public WritableFile { } virtual Status Sync() { + Status s = Flush(); + if (!s.ok()) { + return s; + } TEST_KILL_RANDOM(rocksdb_kill_odds); if (pending_sync_ && fdatasync(fd_) < 0) { return IOError(filename_, errno); @@ -771,6 +775,10 @@ class PosixWritableFile : public WritableFile { } virtual Status Fsync() { + Status s = Flush(); + if (!s.ok()) { + return s; + } TEST_KILL_RANDOM(rocksdb_kill_odds); if (pending_fsync_ && fsync(fd_) < 0) { return IOError(filename_, errno);