ferhui commented on pull request #393:
URL: https://github.com/apache/incubator-ratis/pull/393#issuecomment-760031039


   Detail about this PR, I have post it to jira, and paste it here.
   
   The first while clause in 
TestRetryCacheWithGrpc#testRetryOnResourceUnavailableException
   ```
   while (!failure.get()) {
     long cid = callId;
     r = cluster.newRaftClientRequest(clientId, leaderProxy.getId(), callId++,
         new RaftTestUtil.SimpleMessage("message"));
     CompletableFuture<RaftClientReply> f = 
leaderProxy.submitClientRequestAsync(r);
     f.exceptionally(e -> {
         if (e.getCause() instanceof ResourceUnavailableException) {
           RetryCacheTestUtil.isFailed(RetryCacheTestUtil.get(leader, clientId, 
cid));
           failure.set(true);
         }
         return null;
     });
   }
   ```
   
   There are 2 requests here, and because followers call 
blockWriteStateMachineData, the first request will be blocked, and 
ELEMENT_LIMIT_KEY is 1, the second request will fail and receive 
ResourceUnavailableException.
   
   After quittng the first while clause. Followers call 
unblockWriteStateMachineData
   
   In the second while clause
   ```
   while (failure.get()) {
     try {
     // retry until the request failed with ResourceUnavailableException 
succeeds.
     leaderProxy.submitClientRequestAsync(r).get();
     } catch (Exception e) {
       failure.set(false);
     }
   }
   ```
   
   There are 2 cases: 1. If the first request has been done, the 3rd request 
will be handled, and later requests will hit retrycache, and server will always 
return success. It couldn't get Exception and enter infinite loop. 2. If the 
first request hasn't been done, and the 3rd request has been reach the server, 
it will get   ResourceUnavailableException and set failure true, and quit the 
loop.
   
   Mostly the case 1 occurs, and this UT nearly always fails
   
   So i suggest that quit the loop when request handled successfully as the 
comments say
   
   > // retry until the request failed with ResourceUnavailableException 
succeeds.


----------------------------------------------------------------
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