szetszwo commented on code in PR #1218:
URL: https://github.com/apache/ratis/pull/1218#discussion_r1947901238
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java:
##########
@@ -190,11 +189,10 @@ public void run() {
reload();
}
- final MemoizedSupplier<List<CompletableFuture<Message>>> futures =
applyLog();
- checkAndTakeSnapshot(futures);
+ applyLogFutures = applyLog(applyLogFutures);
+ checkAndTakeSnapshot(applyLogFutures);
if (shouldStop()) {
- checkAndTakeSnapshot(futures);
Review Comment:
We need `applyLogFutures.get()`. Otherwise, it could stop without waiting
the future.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java:
##########
@@ -190,11 +189,10 @@ public void run() {
reload();
}
- final MemoizedSupplier<List<CompletableFuture<Message>>> futures =
applyLog();
- checkAndTakeSnapshot(futures);
+ applyLogFutures = applyLog(applyLogFutures);
Review Comment:
Let's check if `applyLogFutures.isCompletedExceptionally()` before applying
logs.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java:
##########
@@ -263,7 +261,7 @@ private MemoizedSupplier<List<CompletableFuture<Message>>>
applyLog() throws Raf
final long incremented =
appliedIndex.incrementAndGet(debugIndexChange);
Preconditions.assertTrue(incremented == nextIndex);
if (f != null) {
- futures.get().add(f);
+ applyLogFutures = applyLogFutures.thenCombine(f, (previous, current)
-> previous);
Review Comment:
@swamirishi , any update for this?
--
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]