This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 4e5443a4f RATIS-1873. Fix retry cache warning condition (#915)
4e5443a4f is described below
commit 4e5443a4f2e76af060c3725663de3ae73603c50d
Author: William Song <[email protected]>
AuthorDate: Wed Sep 6 02:19:00 2023 +0800
RATIS-1873. Fix retry cache warning condition (#915)
---
ratis-docs/src/site/markdown/configurations.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/configurations.md
b/ratis-docs/src/site/markdown/configurations.md
index 4f6d21555..4e37cfd76 100644
--- a/ratis-docs/src/site/markdown/configurations.md
+++ b/ratis-docs/src/site/markdown/configurations.md
@@ -538,6 +538,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 e561a3cd9..a8a7892dc 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
@@ -793,6 +793,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 c11a1a4c4..40a17c4e9 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
@@ -1777,7 +1777,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()) {