guozhangwang commented on code in PR #13300: URL: https://github.com/apache/kafka/pull/13300#discussion_r1117540370
########## streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java: ########## @@ -863,45 +864,15 @@ public static void addTotalCountAndSumMetricsToSensor(final Sensor sensor, ); } - public static void maybeMeasureLatency(final Runnable actionToMeasure, Review Comment: Moved these util functions to `AbstractTask` since we need them for both standby tasks and active tasks now. ########## streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java: ########## @@ -986,6 +987,11 @@ private void prepareChangelogs(final Set<ChangelogMetadata> newPartitionsToResto } catch (final Exception e) { throw new StreamsException("State restore listener failed on batch restored", e); } + + final TaskId taskId = changelogs.get(partition).stateManager.taskId(); + final StreamTask task = (StreamTask) tasks.get(taskId); + final long recordsToRestore = Math.max(changelogMetadata.restoreEndOffset - startOffset, 0L); + task.recordRestoreRemaining(time, recordsToRestore); Review Comment: The logic for measuring remaining records is a bit complex: we first aggregate the total amount of records to restore across all changelog partitions at the beginning when initializing the changelogs; and then during restoration we keep decrementing by the number of restored records. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org