133tosakarin commented on code in PR #1168:
URL: https://github.com/apache/ratis/pull/1168#discussion_r1805967298


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -613,24 +606,33 @@ private synchronized CompletableFuture<Void> 
changeToFollowerAsync(
     return future;
   }
 
-  synchronized void changeToFollowerAndPersistMetadata(
+  synchronized CompletableFuture<Void> changeToFollowerAndPersistMetadata(
       long newTerm,
       boolean allowListener,
       Object reason) throws IOException {
-    if (changeToFollower(newTerm, false, allowListener, reason)) {
-      state.persistMetadata();
+    final AtomicBoolean metadataUpdated = new AtomicBoolean();
+    final CompletableFuture<Void> future = changeToFollower(newTerm, false, 
allowListener, reason, metadataUpdated);
+    try {
+      if (metadataUpdated.get()) {
+        state.persistMetadata();
+      }
+    } catch (IOException e) {
+      CompletableFuture.runAsync(future::join);

Review Comment:
   I see. 
   
   case 1. We should avoid this situation, which seems to contradict our issue
   case 2. This writing style does not seem to be recommended
   case 3. It seems that we can only use this
   
   Then we can use the third case



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