sanpwc commented on code in PR #2488:
URL: https://github.com/apache/ignite-3/pull/2488#discussion_r1318355938


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -2328,19 +2345,25 @@ private CompletableFuture<Boolean> 
ensureReplicaIsPrimary(ReplicaRequest request
         }
 
         if (expectedTerm != null) {
-            return raftClient.refreshAndGetLeaderWithTerm()
-                    .thenCompose(replicaAndTerm -> {
-                                long currentTerm = replicaAndTerm.term();
-
-                                if (expectedTerm == currentTerm) {
-                                    return completedFuture(null);
+            return placementDriver.getPrimaryReplica(replicationGroupId, 
hybridClock.now().addPhysicalTime(HybridTimestamp.CLOCK_SKEW))
+                    .thenCompose(primaryReplica -> {
+                                long currentEnlistmentConsistencyToken = 
primaryReplica.getStartTime().longValue();
+
+                                if 
(expectedTerm.equals(currentEnlistmentConsistencyToken)) {
+                                    if 
(primaryReplica.getExpirationTime().before(hybridClock.now())) {
+                                        return failedFuture(
+                                                new 
PrimaryReplicaMissException(expectedTerm, currentEnlistmentConsistencyToken));
+                                    } else {
+                                        return completedFuture(null);
+                                    }
                                 } else {
-                                    return failedFuture(new 
PrimaryReplicaMissException(expectedTerm, currentTerm));
+                                    return failedFuture(new 
PrimaryReplicaMissException(expectedTerm, currentEnlistmentConsistencyToken));
                                 }
                             }
                     );
         } else if (request instanceof ReadOnlyReplicaRequest || request 
instanceof ReplicaSafeTimeSyncRequest) {
-            return 
raftClient.refreshAndGetLeaderWithTerm().thenApply(replicaAndTerm -> 
isLocalPeer(replicaAndTerm.leader()));
+            return placementDriver.getPrimaryReplica(replicationGroupId, 
hybridClock.now().addPhysicalTime(HybridTimestamp.CLOCK_SKEW))

Review Comment:
   CLOCK_SKEW addition moved to getPrimaryReplica()



-- 
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-unsubscr...@ignite.apache.org

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

Reply via email to