You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2018/01/30 03:05:42 UTC

[3/3] mesos git commit: Reverted `protobuf::read(path)` to return `Result`.

Reverted `protobuf::read(path)` to return `Result<T>`.

Due to the performance hits of `fsync`, the current implementation
of `state::checkpoint` does not invoke `fsync` prior to `rename`.

As a result, according to this blog post:

  https://thunk.org/tytso/blog/2009/03/12/delayed-allocation-and-
  the-zero-length-file-problem/

If the agent machine crashes after `rename` is called but before
the buffer has been flushed, the file will end up being empty.

This reverts commit 4f9cda17e1a747bc3c4ab3667569304e09600b29.

Review: https://reviews.apache.org/r/65376


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/93a0b842
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/93a0b842
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/93a0b842

Branch: refs/heads/master
Commit: 93a0b842784bc0e71706a3e4f5e11335121441ea
Parents: 97cfc5c
Author: Michael Park <mp...@apache.org>
Authored: Fri Jan 26 12:33:05 2018 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jan 29 18:55:22 2018 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/protobuf.hpp | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/93a0b842/3rdparty/stout/include/stout/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/protobuf.hpp b/3rdparty/stout/include/stout/protobuf.hpp
index 7e76598..7f8ed34 100644
--- a/3rdparty/stout/include/stout/protobuf.hpp
+++ b/3rdparty/stout/include/stout/protobuf.hpp
@@ -340,7 +340,7 @@ Result<T> read(int_fd fd, bool ignorePartial = false, bool undoFailed = false)
 // A wrapper function that wraps the above read() with open and
 // closing the file.
 template <typename T>
-Try<T> read(const std::string& path)
+Result<T> read(const std::string& path)
 {
   Try<int_fd> fd = os::open(
       path,
@@ -358,13 +358,7 @@ Try<T> read(const std::string& path)
   // read(). Also an unsuccessful close() doesn't affect the read.
   os::close(fd.get());
 
-  if (result.isSome()) {
-    return result.get();
-  }
-
-  // `read(fd)` returning `None` here means that the file is empty.
-  // Since this is a partial read of `T`, we report it as an error.
-  return Error(result.isError() ? result.error() : "Found an empty file");
+  return result;
 }