Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RATIS-2176. Update doc for raft.server.log.appender.wait-time.min. #1181

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ratis-docs/src/site/markdown/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ the leader won't send snapshots to follower.
It will just send a notification to that follower instead.
The follower's statemachine is responsible for fetching and installing snapshot by some other means.

| **Property** | `raft.server.log.appender.wait-time.min` |
|:----------------|:-----------------------------------------------|
| **Description** | wait time between two subsequent AppendEntries |
| **Type** | TimeDuration |
| **Default** | 10ms |
| **Property** | `raft.server.log.appender.wait-time.min` |
|:----------------|:---------------------------------------------------------------------------|
| **Description** | wait time between two subsequent AppendEntries. Must be a positive number. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jojochuang , thanks a lot for working on this!

This conf has two purposes:

  1. wait time between two subsequent AppendEntries, and
  2. set to waitForReady in GrpcLogAppender (for the sleep waiting a gRPC stream to ready).

For (1), zero is allowed. For (2), zero becomes 1ms.

Do you think that the usage in (2) is problematic? If yes, we may use a different conf.

| **Type** | TimeDuration |
| **Default** | 1ms |


| **Property** | `raft.server.log.appender.retry.policy` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.LockSupport;

/**
* A new log appender implementation using grpc bi-directional stream API.
Expand Down Expand Up @@ -353,7 +354,8 @@ void onNext(AppendEntriesRequestProto proto)
}
// stall for stream to be ready.
while (!stream.isReady() && running) {
sleep(waitForReady, isHeartBeat);
//sleep(waitForReady, isHeartBeat);
LockSupport.parkNanos(waitForReady.toLong(TimeUnit.NANOSECONDS));
Comment on lines -356 to +358
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jojochuang , thanks for the update! Sorry that I missed the new change earlier.

How about changing it in the sleep(..) method?

@@ -408,12 +409,9 @@ public class GrpcLogAppender extends LogAppenderBase {
 
   private static void sleep(TimeDuration waitTime, boolean heartbeat)
       throws InterruptedIOException {
-    try {
-      waitTime.sleep();
-    } catch (InterruptedException e) {
-      Thread.currentThread().interrupt();
-      throw IOUtils.toInterruptedIOException(
-          "Interrupted appendLog, heartbeat? " + heartbeat, e);
+    LockSupport.parkNanos(waitTime.toLong(TimeUnit.NANOSECONDS));
+    if (Thread.currentThread().isInterrupted()) {
+      throw new InterruptedIOException("Interrupted appendLog, heartbeat? " + heartbeat);
     }
   }

}
stream.onNext(proto);
}
Expand Down
Loading