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


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -800,7 +801,11 @@ private void maybeAdvanceStandbyRestoredOffset(final 
ProcessorStateManager state
                 // the next offset to fetch, not last-applied
                 final OptionalLong lag = restoreConsumer.currentLag(partition);
                 if (lag.isPresent() && lag.getAsLong() == 0L) {
-                    stateManager.advanceRestoredOffsetTo(storeMetadata, 
restoreConsumer.position(partition, Duration.ZERO));
+                    final long position = restoreConsumer.position(partition, 
Duration.ZERO);
+                    stateManager.advanceRestoredOffsetTo(storeMetadata, 
position);
+                    // the end offset is otherwise only learned from a 
restored batch, which never comes when
+                    // there is nothing to restore; like there, it is the last 
offset, -1 for an empty changelog
+                    storeMetadata.setEndOffset(position - 1L);

Review Comment:
   Good catch -- I don't think we should test for 
`restoreConsumer.paused().contains(partition)` though, but rather not iterate 
over paused partitions to begin with. Requires a little bit of refactoring but 
it's not bad, so I think it's cleaner. Pushed an update. Please let me know 
what you think.
   
   Btw: the problem of a lag-report that can get stale is a more general one, 
but something I think we don't need to address. Even if we are in the regular 
warmup-task update path, ie, we get data and update the current-offset via the 
record batches we get from the restore consumer, the moment we get an active 
task assigned, we would pause the warmup, and the lag would "freeze" and could 
get stale.
   
   However, if the warmup task did pass the `acceptable.recovery.lag` 
threshold, it's not an issue if we promote the warmup as active. The lag cannot 
get stale for long in the regular case (max 2 heartbeats: the member reporting 
the lag in it's own heartbeat, which would trigger a refiner step and the 
warmup->active promotion step, plus a second heartbeat for the old owner of the 
active task to learn about it's revocation). -- There is a few corner case in 
which it would take a little longer:
    - the whole group is still in RECONCILING state, for which the refiner 
would not run yet, but only when the group get into STABLE (maybe not too rare 
of a case, but again, should not go on for too long in general)
    - GC fail-over case when not all member RPC versions are known yet -- this 
second one should be more rare than the first one)
    
   Overall, I think we don't need to do anything about it though: what we risk 
is to promote a warmup which is not hot-hot any longer. But the fact that it 
was hot still implies, that it's not a totally cold promotion, so it should be 
fine overall IMHO.
   
   But I thought I share all this for awareness. -- Let me know if you disagree 
and what to get it addressed. The problem though is, if we address it, we could 
trigger the opposite case, and might have a (almost) hot warmup task at hand, 
which we refuse to promote until the active-restore completed. For this case, 
the warmup could indeed become cold again, depending on how long the 
active-restore takes, and the overall e2e latency until all stateful tasks are 
moved could increase. I believe this case might be worse overall?



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