eduwercamacaro commented on code in PR #14735:
URL: https://github.com/apache/kafka/pull/14735#discussion_r1409158503


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:
##########
@@ -701,7 +706,15 @@ private StandbyTask convertActiveToStandby(final 
StreamTask activeTask, final Se
     }
 
     private StreamTask convertStandbyToActive(final StandbyTask standbyTask, 
final Set<TopicPartition> partitions) {
-        return activeTaskCreator.createActiveTaskFromStandby(standbyTask, 
partitions, mainConsumer);
+        final StreamTask streamTask = 
activeTaskCreator.createActiveTaskFromStandby(standbyTask, partitions, 
mainConsumer);
+        final ProcessorStateManager stateManager = standbyTask.stateManager();
+        for (final TopicPartition partition : partitions) {
+            final ProcessorStateManager.StateStoreMetadata storeMetadata = 
stateManager.storeMetadata(partition);
+            if (storeMetadata != null && storeMetadata.endOffset() != null) {
+                standbyTaskUpdateListener.onUpdateSuspended(partition, 
storeMetadata.store().name(), storeMetadata.offset(), 
storeMetadata.endOffset(), StandbyUpdateListener.SuspendReason.PROMOTED);

Review Comment:
   I made some adjustments so that we can tell when a 'Task' has been 
`Migrated` or `Promoted` by looking at its 'ChangelogState' and 'Task' states. 
Basically, in this way:
   
   Task State: `Running` and ChangelogState: `Restoring` => Promoted
   Task State: `Suspended` and ChangelogState: `Restoring` => Migrated
   
   This allows the 'StoreChangelogReader' to infer the cause of the suspension. 
This seems to be true only for state updater, for some reason, when the state 
updater is disabled, Task State is always `Suspended` when `#unregister` gets 
called.



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

Reply via email to