runzhiwang opened a new pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129


   ## What changes were proposed in this pull request?
   What's the problem ?
   The 
[threads](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/test/java/org/apache/ratis/server/simulation/RequestHandler.java#L48)
 in one RequestHandler only process the requests which were sent to one server 
such as s2.
   So request1 from s1 to s2, request2 from s3 to s2 are both processed by one 
RequestHandler. 
   When change oldLeader such as s1, if 
[q.takeRequest()](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRequestReply.java#L138)
 return request1, request1.getRequestorId() will return s1, because 
blockTakeRequestFrom was set true when 
[changeLeader](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java#L386),
 so thread was blocked at  
[RaftTestUtil.block(reqQ.blockTakeRequestFrom::get)](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRequestReply.java#L145),
 if a lot of request from s1 to s2, then all the 
[threads](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/test/java/org/apache/ratis/server/simulation/RequestHandler.java#L48)
 in RequestHandler will be blocked. So new leader can not be elected.
   
   How to fix ?
   When block oldLeader such as s1, we can discard all the request sent by s1 
to other servers.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-868
   
   ## How was this patch tested?
   
   Existed test.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to