szetszwo commented on code in PR #1218:
URL: https://github.com/apache/ratis/pull/1218#discussion_r1962229122
##########
ratis-server-api/src/main/java/org/apache/ratis/statemachine/StateMachine.java:
##########
@@ -244,6 +244,14 @@ default void notifyConfigurationChanged(long term, long
index, RaftConfiguration
*/
default void notifyGroupRemove() {}
+ /**
+ * Notify the {@link StateMachine} a group removal event.
+ * @param applyTransactionFailure true if there was a failure in applying
transaction.
+ */
+ default void notifyGroupRemove(boolean applyTransactionFailure) {
+ notifyGroupRemove();
+ }
Review Comment:
Please don't add `notifyGroupRemove(boolean applyTransactionFailure)` here.
Instead, it should fail the groupRemove request.
BTW, let's change groupRemove in a separated JIRA instead of changing it
here.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -481,14 +481,20 @@ void groupRemove(boolean deleteDirectory, boolean
renameDirectory) {
/* Shutdown is triggered here inorder to avoid any locked files. */
state.getStateMachineUpdater().setRemoving();
close();
+ if (state.getStateMachineUpdater().getError() != null) {
+ LOG.error("{}: groupRemove failed: {}. Falling back to directory
rename.",
+ getGroup().getGroupId(), getMemberId(),
state.getStateMachineUpdater().getError());
+ deleteDirectory = false;
+ renameDirectory = true;
Review Comment:
It seems wrong to change the request silently. We need some design on this.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java:
##########
@@ -263,7 +263,11 @@ 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.exceptionally(ex -> {
+ LOG.error("Exception while {}: applying txn index={}, nextLog={}",
this, nextIndex,
+ LogProtoUtils.toLogEntryString(entry));
+ return null;
+ }), (v, message) -> null);
Review Comment:
Move out `f.exceptionally`, i.e.
```java
f.exceptionally(ex -> {
LOG.error("Exception while {}: applying txn index={},
nextLog={}", this, nextIndex,
LogProtoUtils.toLogEntryString(entry));
return null;
})
applyLogFutures = applyLogFutures.thenCombine(f, (v, message) -> null);
```
--
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]