chia7712 commented on code in PR #23750:
URL: https://github.com/apache/kafka/pull/23750#discussion_r4654405497


##########
share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:
##########
@@ -586,24 +582,28 @@ public 
CoordinatorResult<InitializeShareGroupStateResponseData, CoordinatorRecor
     /**
      * Iterates over the soft state to determine the share partitions whose 
last snapshot is
      * older than the allowed time interval. The candidate share partitions 
are force snapshotted.
+     * <p>
+     * Skipped if all share partitions are cold snapshotted with no pending 
share updates.
      *
      * @return A result containing snapshot records, if any, and a void 
response.
      */
     public CoordinatorResult<Void, CoordinatorRecord> snapshotColdPartitions() 
{
-        long coldSnapshottedPartitionsCount = shareStateMap.values().stream()
-            .filter(shareGroupOffset -> shareGroupOffset.createTimestamp() - 
shareGroupOffset.writeTimestamp() != 0)
-            .count();
-
-        // If all share partitions are snapshotted, it means that
-        // system is quiet and cold snapshotting will not help much.
-        if (coldSnapshottedPartitionsCount == shareStateMap.size()) {
-            log.debug("All share snapshot records already cold snapshotted, 
skipping.");
+        boolean allPartitionsQuiet = shareStateMap.entrySet().stream()
+            .allMatch(entry -> entry.getValue().createTimestamp() != 
entry.getValue().writeTimestamp() &&
+                snapshotUpdateCount.getOrDefault(entry.getKey(), 0) == 0);

Review Comment:
   Could `snapshotUpdateCount.getOrDefault(entry.getKey(), 0) == 0` be replaced 
by `snapshotUpdateCount.isEmpty()`, since `handleShareSnapshot` always drops 
the key now?



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