vldpyatkov commented on code in PR #2078:
URL: https://github.com/apache/ignite-3/pull/2078#discussion_r1198826153


##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/leases/LeaseTracker.java:
##########
@@ -152,4 +195,46 @@ public CompletableFuture<Void> onUpdate(WatchEvent event) {
         public void onError(Throwable e) {
         }
     }
+
+    @Override
+    public CompletableFuture<LeaseMeta> awaitPrimaryReplica(ReplicationGroupId 
groupId, HybridTimestamp timestamp) {
+        if (!busyLock.enterBusy()) {
+            return failedFuture(new NodeStoppingException("Component is 
stopping."));
+        }
+        try {
+            return primaryReplicaWaiters.computeIfAbsent(groupId, id -> new 
PendingIndependentComparableValuesTracker<>(MIN_VALUE))
+                    .waitFor(timestamp);
+        } finally {
+            busyLock.leaveBusy();
+        }
+    }
+
+    @Override
+    public CompletableFuture<LeaseMeta> getPrimaryReplica(ReplicationGroupId 
replicationGroupId, HybridTimestamp timestamp) {
+        if (!busyLock.enterBusy()) {
+            return failedFuture(new NodeStoppingException("Component is 
stopping."));
+        }
+        try {
+            // There's no sense in awaiting previously detected primary 
replica more than lease interval.
+            return awaitPrimaryReplica(replicationGroupId, 
timestamp).orTimeout(longLeaseInterval, TimeUnit.MILLISECONDS);

Review Comment:
   To use safe time is absolutely correct, but any timeout cannot be used as a 
replacement, because any timeout might be violated. Time to spread information 
across cluster does not have time limitation.
   We have only guaranties are related to clock of cluster, but this cannot be 
applied to safe time. Safe time on different nodes might be arbitrary 
different. Hence, we cannot to replace safe time check by checking timeout.



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