mjsax commented on code in PR #23991:
URL: https://github.com/apache/kafka/pull/23991#discussion_r4557139368
##########
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:
> so it keeps reporting lag 0 for the whole active restore
I think the "lag 0" case would only be a corner case, right (eg, empty
changelog, or position==endOffset by chance)? When we transit to active
restore, both position (task-offset) and endOffset (task-end-offset) just
freeze. The lag may be larger than 0 though.
However, while I think the tradeoff I described above is fine for warmup
tasks, I am now wondering if it's a problem for standbys? For a warmup task
which did become hot, even if we get slightly stale offset reporting, we would
promote to active quickly. -- For a standby, there is no planned promotion, and
thus it would keep reporting stale offset for a long period of time (the full
active restore phase). If we get a new rebalance or refiner step later, we
might act on quite outdated offset information... I would not necessarily want
to tackle this problem in this PR though, but might be worth to address as
follow up? For example, if we are in "active restoring" we could issue an extra
"get end-offset" RPC for all pause standby changelog partitions when we need to
report the lag (only every 60 seconds by default); this seems acceptable?
--
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]