denis-chudov commented on code in PR #7018:
URL: https://github.com/apache/ignite-3/pull/7018#discussion_r2576438988


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DataNodesManager.java:
##########
@@ -1065,14 +1064,43 @@ private Operation addNewEntryToDataNodesHistory(
         if (!addMandatoryEntry
                 && !history.isEmpty()
                 && 
nodes.equals(history.dataNodesForTimestamp(HybridTimestamp.MAX_VALUE).dataNodes()))
 {
-            return noop();
+            return null;
         } else {
-            DataNodesHistory newHistory = history.addHistoryEntry(timestamp, 
nodes);
+            HybridTimestamp now = clockService.current();
+            HybridTimestamp earliestTimestampNeededForHistory = 
earliestTimestampNeededForHistory(now);
+            DataNodesHistory newHistory = history
+                    .addHistoryEntry(timestamp, nodes)
+                    .compactIfNeeded(earliestTimestampNeededForHistory);
             dataNodesHistoryVolatile.put(zoneId, newHistory);
-            return put(zoneDataNodesHistoryKey(zoneId), 
DataNodesHistorySerializer.serialize(newHistory));
+
+            int compactedEntriesCount = history.size() - (newHistory.size() - 
1);
+            if (compactedEntriesCount > 0) {
+                LOG.info("Data nodes history compacted [zoneId={}, 
compactedEntriesCount={}, atTimestamp={}, earliestTimestampNeeded={}].",
+                        zoneId, compactedEntriesCount, now, 
earliestTimestampNeededForHistory);
+            }
+
+            return newHistory;
         }
     }
 
+    private Operation addNewEntryOperation(int zoneId, @Nullable 
DataNodesHistory history) {
+        if (history == null) {
+            return noop();
+        } else {
+            return put(zoneDataNodesHistoryKey(zoneId), 
DataNodesHistorySerializer.serialize(history));
+        }
+    }
+
+    private HybridTimestamp earliestTimestampNeededForHistory(HybridTimestamp 
timestamp) {
+        long minTimeAvailable = timestamp.getPhysical()
+                - 
gcConfiguration.lowWatermark().dataAvailabilityTimeMillis().value()
+                - clockService.maxClockSkewMillis();

Review Comment:
   By subtracting the max clock skew, we move the earliest timestamp back in 
time, leaving more history, which is good if clock skew is close to maximum



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