You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "AMashenkov (via GitHub)" <gi...@apache.org> on 2023/01/26 09:20:00 UTC

[GitHub] [ignite-3] AMashenkov commented on a diff in pull request #1579: IGNITE-18446 Add busy lock to raft service

AMashenkov commented on code in PR #1579:
URL: https://github.com/apache/ignite-3/pull/1579#discussion_r1087590114


##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -217,20 +217,24 @@ private Replica startReplicaInternal(
             ReplicationGroupId replicaGrpId,
             ReplicaListener listener
     ) {
+        Replica newReplica = new Replica(replicaGrpId, listener);
+
         replicas.compute(replicaGrpId, (replicationGroupId, replicaFut) -> {
             if (replicaFut == null) {
-                replicaFut = CompletableFuture.completedFuture(new Replica(replicaGrpId, listener));
-
-                return replicaFut;
+                return CompletableFuture.completedFuture(newReplica);
             } else {
-                replicaFut.complete(new Replica(replicaGrpId, listener));
+                if (replicaFut.isDone() && !replicaFut.isCancelled() && !replicaFut.isCompletedExceptionally()) {
+                    return CompletableFuture.completedFuture(newReplica);
+                }
+
+                replicaFut.complete(newReplica);

Review Comment:
   Here we can complete the future inside the synchronized block.
   Should the future be completed in the current thread? or completeAsync should be used instead?



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org