alex-plekhanov commented on code in PR #11633: URL: https://github.com/apache/ignite/pull/11633#discussion_r1836150908
########## modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java: ########## @@ -978,20 +968,26 @@ private void onHistoryAdded( Iterator<HistoryAffinityAssignment> it = affCache.values().iterator(); + AffinityTopologyVersion lastAffChangeTopVer = + ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(head.get().topologyVersion()); + while (it.hasNext()) { HistoryAffinityAssignment aff0 = it.next(); - if (aff0.requiresHistoryCleanup()) { - // We can stop cleanup only on non-shallow item. - // Keeping part of shallow items chain if corresponding real item is missing makes no sense. - if (!shouldContinueCleanup(nonShallowSize, totalSize)) { - nonShallowHistSize.getAndAdd(nonShallowSize - initNonShallowSize); + if (!shouldContinueCleanup(nonShallowSize, totalSize)) { Review Comment: I think the main idea here is thread-safety. There are a lot of methods, which call `initialize` method, that calls `onHistoryAdded`, perhaps this method can be called concurrently. When we atomically substract from `nonShallowHistSize` it's thread safe, when we use `nonShallowHistSize.set` it's not thread safe. -- 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