mjsax commented on code in PR #22595:
URL: https://github.com/apache/kafka/pull/22595#discussion_r3430992989


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdater.java:
##########
@@ -442,6 +448,36 @@ private void 
addToExceptionsAndFailedTasksThenClearUpdatingAndPausedTasks(final
             }
         }
 
+        private void updateTaskOffsetSumSnapshot() {
+            final Map<StreamsRebalanceData.TaskId, Long> snapshot = new 
HashMap<>(updatingTasks.size());
+            for (final Task task : updatingTasks.values()) {
+                if (task.changelogPartitions().isEmpty()) {
+                    continue;
+                }
+                long sum = 0L;
+                boolean unknownOffsetFound = false;
+                for (final Long offset : task.changelogOffsets().values()) {
+                    if (offset == null || offset == OFFSET_UNKNOWN) {
+                        unknownOffsetFound = true;
+                        continue;
+                    }
+                    if (sum > Long.MAX_VALUE - offset) {
+                        sum = Long.MAX_VALUE;
+                        break;
+                    }
+                    sum += offset;
+                }
+                if (unknownOffsetFound && sum != Long.MAX_VALUE) {

Review Comment:
   Yes, this is on purpose. But happy to discuss. -- In the end, we need to 
know when a warmup is hot. If we have an unknown offset, we cannot compute the 
lag. To avoid promoting a warmup too early, I would like to be conservative, 
and using `0` here would give us the largest lag, avoiding per-mature promotion.
   
   I was also thinking about broker side changes. Atm, there is no contract 
between the client/broker (ie, nothing defined in KIP-1071) what a negative 
offset-sum would mean. Again, if we just send 0 it seems we can avoid to add 
corner case handling in the GC code, and just rely on the conservative "max 
lag" estimation, as fallback).
   
   Thoughts? -- I am frankly not sure why it was done differently in the 
existing code, and it doesn't really make much sense to me how it's done.



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