You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2018/01/05 06:31:55 UTC
incubator-ratis git commit: RATIS-177. Raft Leader should not return
LeaderNotReady Exception for old completed requests. Contributed by Lokesh
Jain
Repository: incubator-ratis
Updated Branches:
refs/heads/master 00f80b446 -> 7a955ef43
RATIS-177. Raft Leader should not return LeaderNotReady Exception for old completed requests. Contributed by Lokesh Jain
Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/7a955ef4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/7a955ef4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/7a955ef4
Branch: refs/heads/master
Commit: 7a955ef438af44de89f031c49ec1bb763361d06a
Parents: 00f80b4
Author: Tsz-Wo Nicholas Sze <sz...@hortonworks.com>
Authored: Fri Jan 5 14:31:17 2018 +0800
Committer: Tsz-Wo Nicholas Sze <sz...@hortonworks.com>
Committed: Fri Jan 5 14:31:17 2018 +0800
----------------------------------------------------------------------
.../java/org/apache/ratis/server/impl/RaftServerImpl.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/7a955ef4/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
----------------------------------------------------------------------
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index 89ea019..d039e6c 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -367,10 +367,12 @@ public class RaftServerImpl implements RaftServerProtocol,
NotLeaderException exception = generateNotLeaderException();
final RaftClientReply reply = new RaftClientReply(request, exception);
return RetryCache.failWithReply(reply, entry);
- } else {
- if (leaderState == null || !leaderState.isReady()) {
- return RetryCache.failWithException(new LeaderNotReadyException(getId()), entry);
+ } else if (leaderState == null || !leaderState.isReady()) {
+ RetryCache.CacheEntry cacheEntry = retryCache.get(request.getClientId(), request.getCallId());
+ if (cacheEntry != null && cacheEntry.isCompletedNormally()) {
+ return cacheEntry.getReplyFuture();
}
+ return RetryCache.failWithException(new LeaderNotReadyException(getId()), entry);
}
return null;
}