You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2017/08/26 00:08:38 UTC

kudu git commit: KUDU-2102: fix PosixRWFile::Sync to guarantee durability when used concurrently

Repository: kudu
Updated Branches:
  refs/heads/master 2895538e9 -> 9a07b2fed


KUDU-2102: fix PosixRWFile::Sync to guarantee durability when
used concurrently

PosixRWFile has an AtomicBool to optimize the perfomance of Sync()
so that when two threads call Sync() at the same time, only one will
actually do the fsync(). However, the optimization may result in one
thread returning from the call early and operating under the assumption
that the file's data has been made durable, even though it is still in
the process of being synchronized to disk.

This patch fixes this issue simply by removing the optimization. Since
the overhead of no-op fsync() is purely syscall-related, this optimization
wasn't meaningful to begin with.

Change-Id: Ifaf2686233b2553de6d4a4c76fa67cc48dd340d4
Reviewed-on: http://gerrit.cloudera.org:8080/7835
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Adar Dembo <ad...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/9a07b2fe
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9a07b2fe
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9a07b2fe

Branch: refs/heads/master
Commit: 9a07b2fedcc0beacc76cb1c656be84c0c99c9da9
Parents: 2895538
Author: hahao <ha...@cloudera.com>
Authored: Fri Aug 25 13:49:56 2017 -0700
Committer: Dan Burkert <da...@apache.org>
Committed: Sat Aug 26 00:08:20 2017 +0000

----------------------------------------------------------------------
 src/kudu/util/env_posix.cc | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9a07b2fe/src/kudu/util/env_posix.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env_posix.cc b/src/kudu/util/env_posix.cc
index 58c3984..3d45c13 100644
--- a/src/kudu/util/env_posix.cc
+++ b/src/kudu/util/env_posix.cc
@@ -48,7 +48,6 @@
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/strings/split.h"
 #include "kudu/gutil/strings/substitute.h"
-#include "kudu/util/atomic.h"
 #include "kudu/util/debug/trace_event.h"
 #include "kudu/util/env.h"
 #include "kudu/util/errno.h"
@@ -742,7 +741,6 @@ class PosixRWFile : public RWFile {
       : filename_(std::move(fname)),
         fd_(fd),
         sync_on_close_(sync_on_close),
-        pending_sync_(false),
         is_on_xfs_(false),
         closed_(false) {}
 
@@ -765,7 +763,6 @@ class PosixRWFile : public RWFile {
 
   virtual Status WriteV(uint64_t offset, const vector<Slice> &data) OVERRIDE {
     Status s = DoWriteV(fd_, filename_, offset, data);
-    pending_sync_.Store(true);
     return s;
   }
 
@@ -862,10 +859,6 @@ class PosixRWFile : public RWFile {
   }
 
   virtual Status Sync() OVERRIDE {
-    if (!pending_sync_.CompareAndSwap(true, false)) {
-      return Status::OK();
-    }
-
     TRACE_EVENT1("io", "PosixRWFile::Sync", "path", filename_);
     ThreadRestrictions::AssertIOAllowed();
     LOG_SLOW_EXECUTION(WARNING, 1000, Substitute("sync call for $0", filename())) {
@@ -993,7 +986,6 @@ class PosixRWFile : public RWFile {
   const bool sync_on_close_;
 
   GoogleOnceDynamic once_;
-  AtomicBool pending_sync_;
   bool is_on_xfs_;
   bool closed_;
 };