vvcephei commented on a change in pull request #8776:
URL: https://github.com/apache/kafka/pull/8776#discussion_r435523829



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
##########
@@ -613,10 +604,14 @@ private long sumOfChangelogOffsets(final TaskId id, final 
Map<TopicPartition, Lo
         for (final Map.Entry<TopicPartition, Long> changelogEntry : 
changelogOffsets.entrySet()) {
             final long offset = changelogEntry.getValue();
 
-            offsetSum += offset;
-            if (offsetSum < 0) {
-                log.warn("Sum of changelog offsets for task {} overflowed, 
pinning to Long.MAX_VALUE", id);
-                return Long.MAX_VALUE;
+            if (offset == Task.LATEST_OFFSET) {
+                return Task.LATEST_OFFSET;
+            } else {
+                offsetSum += offset;

Review comment:
       It might be nice to have a sanity check here that `offset` is 
non-negative, since that would indicate we've unexpectedly received a sentinel 
value. I thought we did that already, but it's obviously not here.

##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
##########
@@ -613,10 +604,14 @@ private long sumOfChangelogOffsets(final TaskId id, final 
Map<TopicPartition, Lo
         for (final Map.Entry<TopicPartition, Long> changelogEntry : 
changelogOffsets.entrySet()) {
             final long offset = changelogEntry.getValue();
 
-            offsetSum += offset;
-            if (offsetSum < 0) {
-                log.warn("Sum of changelog offsets for task {} overflowed, 
pinning to Long.MAX_VALUE", id);
-                return Long.MAX_VALUE;
+            if (offset == Task.LATEST_OFFSET) {

Review comment:
       This seems pretty subtle, can you convert your GH explanation into a 
code comment?
   
   It also seems mentioning that we assume that if any changelog offset in the 
task is "latest", then we assume the whole task is active and therefore return 
"latest". Took me a minute to work that out.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to