denis-chudov commented on code in PR #7769:
URL: https://github.com/apache/ignite-3/pull/7769#discussion_r2935404710
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -486,11 +486,33 @@ private void updateLeaseBatchInternal() {
: lease.proposedCandidate();
InternalClusterNode candidate =
nextLeaseHolder(stableAssignments, pendingAssignments, grpId,
proposedLeaseholder);
+ boolean leaseholderIdIsInLogicalTopology =
lease.getLeaseholderId() != null
+ &&
topologyTracker.containsNodeId(lease.getLeaseholderId());
+ boolean hasStaleLeaseholderId = lease.isAccepted() &&
!leaseholderIdIsInLogicalTopology;
boolean canBeProlonged = lease.isAccepted()
&& lease.isProlongable()
+ && !hasStaleLeaseholderId
&& candidate != null &&
candidate.id().equals(lease.getLeaseholderId());
+ if (hasStaleLeaseholderId) {
+ LOG.info("Leaseholder has left the logical topology,
creating a new lease [groupId={}, lease={}, candidate={}]",
+ grpId, lease, candidate);
+
+ if (candidate == null) {
+ logGroupWithoutCandidateOnce(grpId, true,
stableAssignments, pendingAssignments);
+ continue;
+ }
+
+ Lease newLease = writeNewLease(grpId, candidate,
renewedLeases);
+
+ boolean force = Objects.equals(lease.getLeaseholder(),
candidate.name());
+
+ toBeNegotiated.put(grpId, new LeaseAgreement(newLease,
force));
+
+ continue;
+ }
+
Review Comment:
actually, all you need is to exclude the outcome when
`tryToFindCandidateAmongAssignments` returns stale candidate, that could be
much more simple
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/TopologyTracker.java:
##########
@@ -106,6 +107,27 @@ public void stopTrack() {
return null;
}
+ /**
+ * Returns {@code true} if the logical topology snapshot contains a node
with the given transient node id.
+ *
+ * @param nodeId Node id.
+ */
+ public boolean containsNodeId(UUID nodeId) {
+ LogicalTopologySnapshot logicalTopologySnap0 = topologySnapRef.get();
+
+ if (logicalTopologySnap0 == null ||
CollectionUtils.nullOrEmpty(logicalTopologySnap0.nodes())) {
+ return false;
+ }
+
+ for (LogicalNode node : logicalTopologySnap0.nodes()) {
+ if (node.id().equals(nodeId)) {
+ return true;
+ }
+ }
+
Review Comment:
probably, this method and `nodeByConsistentId` should be refactored
--
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]