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


   What's the problem ?
   {code:java}
   ava.lang.AssertionError: expected:<19> but was:<20>
        at 
org.apache.ratis.logservice.server.TestMetaServer.testJMXCount(TestMetaServer.java:339)
        at 
org.apache.ratis.logservice.server.TestMetaServer.testListLogs(TestMetaServer.java:331)
   {code}
   
   What's the reason ?
   1. when create log, it will call 
[RaftClientImpl::sendRequestWithRetry](https://github.com/apache/incubator-ratis/blob/master/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java#L285),
 if throw TimeoutIOException, it will retry at [final RaftClientReply reply = 
sendRequest(request)](https://github.com/apache/incubator-ratis/blob/master/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java#L296),
 So JMXCount will increase many times at [timerContext = 
metricRegistry.timer(type.name()).time()](https://github.com/apache/incubator-ratis/blob/master/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/MetaStateMachine.java#L224]
 when retry happens.  Then JMXCount i.e. 20 not equal to createCount i.e. 19
   
   2. The TimeoutIOException is as follows:
   
   {code:java}
   org.apache.ratis.protocol.TimeoutIOException: deadline exceeded after 
2.999977899s. [buffered_nanos=1460409, remote_addr=localhost/127.0.0.1:9001]
   {code}
   
   3.  The reason of TimeoutIOException is when create log, it will call 
[client.groupAdd](https://github.com/apache/incubator-ratis/blob/master/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/MetaStateMachine.java#L325).
 When add a new group, the following code 
[file.write(jvmName.getBytes(StandardCharsets.UTF_8))](https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageDirectory.java#L342)
 and 
[((FileOutputStream)out).getChannel().force(true)](https://github.com/apache/incubator-ratis/blob/master/ratis-common/src/main/java/org/apache/ratis/util/AtomicFileOutputStream.java)
 will both force sync data to disk. The force sync to disk sometimes cost more 
than 2 seconds, but the timeout threshold of groupAdd is 3 seconds, so 
TimeoutIOException happens.
   
   How to fix ?
   Increase the timeout threshold from 3 seconds to 15 seconds.


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