nizhikov commented on code in PR #11633: URL: https://github.com/apache/ignite/pull/11633#discussion_r1836062197
########## modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java: ########## @@ -946,29 +946,19 @@ private void onHistoryAdded( HistoryAffinityAssignment replaced, HistoryAffinityAssignment added ) { - boolean cleanupNeeded = false; - if (replaced == null) { - cleanupNeeded = true; - - if (added.requiresHistoryCleanup()) + if (added.isFullSizeInstance()) Review Comment: Let's hav this method like the following: ``` private void onHistoryAdded( HistoryAffinityAssignment replaced, HistoryAffinityAssignment added ) { if (replaced == null) { if (added.requiresHistoryCleanup()) nonShallowHistSize.incrementAndGet(); } else if (replaced.requiresHistoryCleanup() != added.requiresHistoryCleanup()) nonShallowHistSize.addAndGet(added.requiresHistoryCleanup() ? 1 : -1); int nonShallowSize = nonShallowHistSize.get(); int totalSize = affCache.size(); if (!shouldContinueCleanup(nonShallowSize, totalSize)) return; AffinityTopologyVersion lastAffChangeTopVer = ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(head.get().topologyVersion()); HistoryAffinityAssignment aff0 = null; Iterator<HistoryAffinityAssignment> it = affCache.values().iterator(); while (it.hasNext() && shouldContinueCleanup(nonShallowSize, totalSize)) { aff0 = it.next(); if (aff0.topologyVersion().equals(lastAffChangeTopVer)) continue; // Keep lastAffinityChangedTopologyVersion, it's required for some operations. if (aff0.requiresHistoryCleanup()) { if (nonShallowSize <= MIN_NON_SHALLOW_HIST_SIZE) continue; nonShallowSize--; } totalSize--; it.remove(); } nonShallowHistSize.set(nonShallowSize); ctx.affinity().removeCachedAffinity(aff0.topologyVersion()); assert it.hasNext() : "All elements have been removed from affinity cache during cleanup"; } ``` -- 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