ramu11 commented on code in PR #23298:
URL: https://github.com/apache/kafka/pull/23298#discussion_r3975186389
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -769,6 +775,41 @@ private int restoreChangelog(final Task task, final
ChangelogMetadata changelogM
return numRecords;
}
+ /**
+ * Advance a standby store's restored offset only at a confirmed catch-up
boundary (KAFKA-14302).
+ * A zero-record poll is not sufficient: retention seeks, source-changelog
buffering, and incomplete
+ * fetches can all leave the consumer at a non-zero position while records
remain to apply.
+ */
+ private void maybeAdvanceStandbyRestoredOffset(final ProcessorStateManager
stateManager,
+ final ChangelogMetadata
changelogMetadata,
+ final StateStoreMetadata
storeMetadata,
+ final TopicPartition
partition) {
+ if (!changelogMetadata.bufferedRecords().isEmpty()) {
+ return;
+ }
+ try {
+ final Long restoreEndOffset = changelogMetadata.restoreEndOffset;
+ if (restoreEndOffset == null) {
+ // Dedicated changelog: no restoreEndOffset. lag == 0 with an
empty buffer means
+ // the restore consumer is at LEO and every fetched record has
already been applied.
+ // position() is the next-fetch boundary, not a last-applied
offset.
+ final OptionalLong lag = restoreConsumer.currentLag(partition);
+ if (lag.isPresent() && lag.getAsLong() == 0L) {
+ stateManager.advanceRestoredOffsetTo(storeMetadata,
restoreConsumer.position(partition));
+ }
+ } else if (restoreEndOffset > 0L) {
+ // Source changelog: restoreEndOffset is the committed-offset
limit. Advertise
+ // only that boundary, never live position past
unapplied/uncommitted records.
Review Comment:
Thanks for the suggestion. Updated the comment to use “limit” instead of
“boundary.”
--
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]