AndrewJSchofield commented on code in PR #19443: URL: https://github.com/apache/kafka/pull/19443#discussion_r2047031680
########## share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java: ########## @@ -574,6 +575,46 @@ public CoordinatorResult<InitializeShareGroupStateResponseData, CoordinatorRecor return new CoordinatorResult<>(List.of(record), responseData); } + /** + * 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. + * + * @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 != 0 && coldSnapshottedPartitionsCount == shareStateMap.size()) { Review Comment: I'm uncertain about this test. If the share state map is empty, then this if condition will be false, and we will proceed to do zero snapshots. Surely, this is a situation which should skip the snapshotting. What's wrong with just `coldSnapshottedPartitionsCount == shareStateMap.size()`? I know the code previously did that, but it seems a better test than what is there 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org