This is an automated email from the ASF dual-hosted git repository.

williamsong pushed a commit to branch snapshot-branch2
in repository https://gitbox.apache.org/repos/asf/ratis.git

commit 284ecbb25cb60a2ea3fde07fb71672fb122f53ac
Author: William Song <[email protected]>
AuthorDate: Wed Sep 6 02:19:00 2023 +0800

    RATIS-1884. Fix retry cache warning condition (#915)
    
    (cherry picked from commit 4e5443a4f2e76af060c3725663de3ae73603c50d)
---
 ratis-docs/src/site/markdown/configuraions.md                           | 2 ++
 .../src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java     | 1 +
 .../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java      | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ratis-docs/src/site/markdown/configuraions.md 
b/ratis-docs/src/site/markdown/configuraions.md
index 80e87fc4b..a0b79715b 100644
--- a/ratis-docs/src/site/markdown/configuraions.md
+++ b/ratis-docs/src/site/markdown/configuraions.md
@@ -544,6 +544,8 @@ Note that `slowness.timeout` is use in two places:
 | **Description** | expire time of retry cache entry     |
 | **Type**        | TimeDuration                         |
 | **Default**     | 60s                                  |
+Note that we should set an expiration time longer than the total retry waiting 
duration of clients 
+in order to ensure exactly-once semantic.
 
 | **Property**    | `raft.server.retrycache.statistics.expire-time` |
 |:----------------|:------------------------------------------------|
diff --git 
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
 
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
index 8665c8874..d095af20c 100644
--- 
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
+++ 
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
@@ -761,6 +761,7 @@ public interface RaftServerConfigKeys {
   interface RetryCache {
     String PREFIX = RaftServerConfigKeys.PREFIX + ".retrycache";
 
+    /** We should set expiry time longer than total client retry to guarantee 
exactly-once semantic */
     String EXPIRY_TIME_KEY = PREFIX + ".expirytime";
     TimeDuration EXPIRY_TIME_DEFAULT = TimeDuration.valueOf(60, 
TimeUnit.SECONDS);
     static TimeDuration expiryTime(RaftProperties properties) {
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 9f3f7982d..55a5f499b 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
@@ -1731,7 +1731,7 @@ class RaftServerImpl implements RaftServer.Division,
     // update the retry cache
     final CacheEntry cacheEntry = retryCache.getOrCreateEntry(invocationId);
     Preconditions.assertTrue(cacheEntry != null);
-    if (getInfo().isLeader() && !cacheEntry.isCompletedNormally()) {
+    if (getInfo().isLeader() && cacheEntry.isCompletedNormally()) {
       LOG.warn("{} retry cache entry of leader should be pending: {}", this, 
cacheEntry);
     }
     if (cacheEntry.isFailed()) {

Reply via email to