szetszwo commented on a change in pull request #616:
URL: https://github.com/apache/ratis/pull/616#discussion_r820032942



##########
File path: 
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogWorker.java
##########
@@ -371,21 +372,32 @@ private void flushIfNecessary() throws IOException {
         if (stateMachineDataPolicy.isSync()) {
           stateMachineDataPolicy.getFromFuture(f, () -> this + 
"-flushStateMachineData");
         }
-        final Timer.Context logSyncTimerContext = raftLogSyncTimer.time();
         flushBatchSize = (int)(lastWrittenIndex - flushIndex.get());
-        out.flush();
-        logSyncTimerContext.stop();
+        if (flushExecutorWorkQueue.isEmpty()) {

Review comment:
       Good point!

##########
File path: 
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogWorker.java
##########
@@ -371,21 +372,32 @@ private void flushIfNecessary() throws IOException {
         if (stateMachineDataPolicy.isSync()) {
           stateMachineDataPolicy.getFromFuture(f, () -> this + 
"-flushStateMachineData");
         }
-        final Timer.Context logSyncTimerContext = raftLogSyncTimer.time();
         flushBatchSize = (int)(lastWrittenIndex - flushIndex.get());
-        out.flush();
-        logSyncTimerContext.stop();
+        if (flushExecutorWorkQueue.isEmpty()) {
+          CompletableFuture.supplyAsync(this::flushOutStream, flushExecutor);

Review comment:
       Since it is async, it may call updateFlushedIndexIncreasingly() before 
flush actually has completed.  It is incorrect.




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

To unsubscribe, e-mail: [email protected]

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


Reply via email to