You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/06/17 14:26:25 UTC

[GitHub] [incubator-ratis] runzhiwang opened a new pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

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:
users@infra.apache.org



[GitHub] [incubator-ratis] lokeshj1703 commented on a change in pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on a change in pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129#discussion_r452142452



##########
File path: ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRequestReply.java
##########
@@ -130,19 +130,23 @@ public REQUEST takeRequest(String qid) throws IOException {
       throw new IOException("The RPC of " + qid + " has already shutdown.");
     }
 
-    final REQUEST request;
+    REQUEST request;
     try {
       // delay request for testing
       RaftTestUtil.delay(q.delayTakeRequestTo::get);
-
-      request = q.takeRequest();
-      Preconditions.assertTrue(qid.equals(request.getReplierId()));
-
-      // block request for testing
-      final EventQueue<REQUEST, REPLY> reqQ = queues.get(request.getRequestorId());
-      if (reqQ != null) {
-        RaftTestUtil.delay(reqQ.delayTakeRequestFrom::get);
-        RaftTestUtil.block(reqQ.blockTakeRequestFrom::get);
+      while (true) {
+        request = q.takeRequest();
+        Preconditions.assertTrue(qid.equals(request.getReplierId()));
+
+        final EventQueue<REQUEST, REPLY> reqQ = queues.get(request.getRequestorId());
+        if (reqQ != null) {
+          // discard request for testing

Review comment:
       We can update the comment that we are doing a busy wait here.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] runzhiwang closed pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
runzhiwang closed pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] runzhiwang commented on a change in pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
runzhiwang commented on a change in pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129#discussion_r452651782



##########
File path: ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRequestReply.java
##########
@@ -130,19 +130,23 @@ public REQUEST takeRequest(String qid) throws IOException {
       throw new IOException("The RPC of " + qid + " has already shutdown.");
     }
 
-    final REQUEST request;
+    REQUEST request;
     try {
       // delay request for testing
       RaftTestUtil.delay(q.delayTakeRequestTo::get);
-
-      request = q.takeRequest();
-      Preconditions.assertTrue(qid.equals(request.getReplierId()));
-
-      // block request for testing
-      final EventQueue<REQUEST, REPLY> reqQ = queues.get(request.getRequestorId());
-      if (reqQ != null) {
-        RaftTestUtil.delay(reqQ.delayTakeRequestFrom::get);
-        RaftTestUtil.block(reqQ.blockTakeRequestFrom::get);
+      while (true) {
+        request = q.takeRequest();
+        Preconditions.assertTrue(qid.equals(request.getReplierId()));
+
+        final EventQueue<REQUEST, REPLY> reqQ = queues.get(request.getRequestorId());
+        if (reqQ != null) {
+          // discard request for testing

Review comment:
       @lokeshj1703 Thanks for review. I have updated the PR.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] runzhiwang commented on pull request #129: RATIS-868. Fix TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
runzhiwang commented on pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129#issuecomment-645391013


   @bshashikant @lokeshj1703 Could you help review this patch ? Thank you very much.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] lokeshj1703 commented on pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129#issuecomment-656543885


   @runzhiwang Thanks for the contribution! I have committed it to master branch.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] runzhiwang closed pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
runzhiwang closed pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-ratis] lokeshj1703 closed pull request #129: RATIS-868. Fix Failed UT: TestRaftWithSimulatedRpc#testWithLoad

Posted by GitBox <gi...@apache.org>.
lokeshj1703 closed pull request #129:
URL: https://github.com/apache/incubator-ratis/pull/129


   


----------------------------------------------------------------
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:
users@infra.apache.org