[ 
https://issues.apache.org/jira/browse/RATIS-458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16992878#comment-16992878
 ] 

Tsz-wo Sze commented on RATIS-458:
----------------------------------

The approach looks great.  Just one question:
- Should we timeout non-heart append requests?  It seems not useful as 
discussed previously.

Some other comments
- Let's add a isHeartbeat field to AppendEntriesReplyProto and 
StatusRuntimeException.  Then the leader side is more deterministic.

- Let's add a RequestMap class as below
{code}
//GrpcLogAppender
  static class RequestMap {
    private final Map<Long, AppendEntriesRequest> logRequests = new 
ConcurrentHashMap<>();
    private final Map<Long, AppendEntriesRequest> heartbeats = new 
ConcurrentHashMap<>();

    int logRequestsSize() {
      return logRequests.size();
    }

    void clear() {
      logRequests.clear();
      heartbeats.clear();
    }

    void put(AppendEntriesRequest request) {
      if (request.isHeartbeat()) {
        heartbeats.put(request.getCallId(), request);
      } else {
        logRequests.put(request.getCallId(), request);
      }
    }

    AppendEntriesRequest remove(AppendEntriesReplyProto reply) {
      return remove(reply.getServerReply().getCallId(), reply.isHeartbeat());
    }

    AppendEntriesRequest remove(long cid, boolean isHeartbeat) {
      return isHeartbeat? heartbeats.remove(cid): logRequests.remove(cid);
    }
  }
{code}
and use it as pendingRequests.
{code}
  private final RequestMap pendingRequests = new RequestMap();
{code}


- Let move futures variable down and keep it final.
{code}
//RaftServerImpl.appendEntriesAsync
    final List<CompletableFuture<Long>> futures = entries.length == 0? 
Collections.emptyList()
        : state.getLog().append(entries);
{code}


> GrpcLogAppender#shouldWait should wait on pending log entries to follower
> -------------------------------------------------------------------------
>
>                 Key: RATIS-458
>                 URL: https://issues.apache.org/jira/browse/RATIS-458
>             Project: Ratis
>          Issue Type: Improvement
>          Components: gRPC
>            Reporter: Lokesh Jain
>            Assignee: Lokesh Jain
>            Priority: Major
>              Labels: ozone
>         Attachments: RATIS-458.001.patch, RATIS-458.002.patch, 
> RATIS-458.003.patch, RATIS-458.004.patch, RATIS-458.005.patch, 
> RATIS-458.006.patch, RATIS-458.007.patch
>
>
> In GrpcLogAppender when an append entry times out we remove the entry from 
> the pendingRequests. This decreases the size of pendingRequests which affects 
> the logic in GrpcLogAppender#shouldWait. Further we also consider heartbeats 
> in shouldWait because heartbeats are tracked in pendingRequests. It should 
> actually wait on the number of log entries which are appended to follower but 
> have not yet been processed by it.
> GrpcConfigKeys.Server.leaderOutstandingAppendsMax should also be a fraction 
> of RaftServerConfigKeys.Log.queueSize. This brings flow control for leader's 
> append entries to follower because then number of outstanding append entries 
> in leader would be limited by maximum number of operations in raft log worker.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to