Skip to content

Commit

Permalink
watchman: eden: remove ESTALE handling
Browse files Browse the repository at this point in the history
Summary:
We resolved the cause of the ESTALE errors inside edenfs
a while back; we can remove this workaround logic now.

Reviewed By: chadaustin

Differential Revision: D22584175

fbshipit-source-id: eb39b26e8e3a23abf1d557d38f4159d3571349ad
  • Loading branch information
wez authored and facebook-github-bot committed Jul 18, 2020
1 parent af65d73 commit 0982fbf
Showing 1 changed file with 8 additions and 46 deletions.
54 changes: 8 additions & 46 deletions watcher/eden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,40 +147,6 @@ class SettleCallback : public folly::HHWheelTimer::Callback {
std::shared_ptr<w_root_t> root_;
};

/** Execute a functor, retrying it if we encounter an ESTALE exception.
* Ideally ESTALE wouldn't happen but we've been unable to figure out
* exactly what is happening on the Eden side so far, and it is more
* expedient to add a basic retry to ensure smoother operation
* for watchman clients. */
template <typename FUNC>
auto retryEStale(FUNC&& func) {
constexpr size_t kNumRetries = 5;
std::chrono::milliseconds backoff(1);
for (size_t retryAttemptsRemaining = kNumRetries; retryAttemptsRemaining >= 0;
--retryAttemptsRemaining) {
try {
return func();
} catch (const std::system_error& exc) {
if (exc.code() != error_code::stale_file_handle ||
retryAttemptsRemaining == 0) {
throw;
}
// Try again
log(ERR,
"Got ESTALE error from eden; will retry ",
retryAttemptsRemaining,
" more times. (",
exc.what(),
")\n");
/* sleep override */ std::this_thread::sleep_for(backoff);
backoff *= 2;
continue;
}
}
throw std::runtime_error(
"unreachable line reached; should have thrown an ESTALE");
}

// Resolve the eden socket; On POSIX systems we use the .eden dir that is
// present in every dir of an eden mount to locate the symlink to the socket.
// On Windows systems, .eden is only present in the repo root and contains
Expand Down Expand Up @@ -213,13 +179,11 @@ folly::SocketAddress getEdenSocketAddress(w_string_piece rootPath) {
std::unique_ptr<StreamingEdenServiceAsyncClient> getEdenClient(
w_string_piece rootPath,
folly::EventBase* eb = folly::EventBaseManager::get()->getEventBase()) {
return retryEStale([&] {
auto addr = getEdenSocketAddress(rootPath);
auto addr = getEdenSocketAddress(rootPath);

return make_unique<StreamingEdenServiceAsyncClient>(
apache::thrift::HeaderClientChannel::newChannel(
AsyncSocket::newSocket(eb, addr)));
});
return make_unique<StreamingEdenServiceAsyncClient>(
apache::thrift::HeaderClientChannel::newChannel(
AsyncSocket::newSocket(eb, addr)));
}

/** Create a thrift client that will connect to the eden server associated
Expand All @@ -229,13 +193,11 @@ std::unique_ptr<StreamingEdenServiceAsyncClient> getEdenClient(
std::unique_ptr<StreamingEdenServiceAsyncClient> getRocketEdenClient(
w_string_piece rootPath,
folly::EventBase* eb = folly::EventBaseManager::get()->getEventBase()) {
return retryEStale([&] {
auto addr = getEdenSocketAddress(rootPath);
auto addr = getEdenSocketAddress(rootPath);

return make_unique<StreamingEdenServiceAsyncClient>(
apache::thrift::RocketClientChannel::newChannel(
AsyncSocket::UniquePtr(new AsyncSocket(eb, addr))));
});
return make_unique<StreamingEdenServiceAsyncClient>(
apache::thrift::RocketClientChannel::newChannel(
AsyncSocket::UniquePtr(new AsyncSocket(eb, addr))));
}

class EdenFileResult : public FileResult {
Expand Down

0 comments on commit 0982fbf

Please sign in to comment.