guozhangwang commented on code in PR #12554:
URL: https://github.com/apache/kafka/pull/12554#discussion_r955703738
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java:
##########
@@ -673,44 +772,11 @@ private void handleRemovedTasksFromStateUpdater() {
final Set<Task> tasksToCloseDirty = new
TreeSet<>(Comparator.comparing(Task::id));
for (final Task task : stateUpdater.drainRemovedTasks()) {
- final TaskId taskId = task.id();
Set<TopicPartition> inputPartitions;
if ((inputPartitions =
tasks.removePendingTaskToRecycle(task.id())) != null) {
- try {
- final Task newTask = task.isActive() ?
- convertActiveToStandby((StreamTask) task,
inputPartitions) :
- convertStandbyToActive((StandbyTask) task,
inputPartitions);
- newTask.initializeIfNeeded();
- stateUpdater.add(newTask);
- } catch (final RuntimeException e) {
- final String uncleanMessage = String.format("Failed to
recycle task %s cleanly. " +
- "Attempting to handle remaining tasks before
re-throwing:", taskId);
- log.error(uncleanMessage, e);
-
- if (task.state() != State.CLOSED) {
- tasksToCloseDirty.add(task);
- }
-
- taskExceptions.putIfAbsent(taskId, e);
- }
+ recycleTask(task, inputPartitions, tasksToCloseDirty,
taskExceptions);
} else if (tasks.removePendingTaskToCloseClean(task.id())) {
- try {
- task.suspend();
- task.closeClean();
- if (task.isActive()) {
-
activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(task.id());
- }
- } catch (final RuntimeException e) {
- final String uncleanMessage = String.format("Failed to
close task %s cleanly. " +
- "Attempting to handle remaining tasks before
re-throwing:", task.id());
- log.error(uncleanMessage, e);
-
- if (task.state() != State.CLOSED) {
- tasksToCloseDirty.add(task);
- }
-
- taskExceptions.putIfAbsent(task.id(), e);
- }
+ closeTaskClean(task, tasksToCloseDirty, taskExceptions);
Review Comment:
Sounds good :) Let's do the queue merging in follow-up PRs then.
--
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]