-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-9620: Do not throw in the middle of consumer user callbacks #8187
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,12 +198,19 @@ public void handleAssignment(final Map<TaskId, Set<TopicPartition>> activeTasks, | |
} | ||
|
||
if (!taskCloseExceptions.isEmpty()) { | ||
for (final Map.Entry<TaskId, RuntimeException> entry : taskCloseExceptions.entrySet()) { | ||
if (!(entry.getValue() instanceof TaskMigratedException)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good |
||
throw new RuntimeException( | ||
"Unexpected failure to close " + taskCloseExceptions.size() + | ||
" task(s) [" + taskCloseExceptions.keySet() + "]. " + | ||
"First unexpected exception (for task " + entry.getKey() + ") follows.", entry.getValue() | ||
); | ||
} | ||
} | ||
|
||
final Map.Entry<TaskId, RuntimeException> first = taskCloseExceptions.entrySet().iterator().next(); | ||
throw new RuntimeException( | ||
"Unexpected failure to close " + taskCloseExceptions.size() + | ||
" task(s) [" + taskCloseExceptions.keySet() + "]. " + | ||
"First exception (for task " + first.getKey() + ") follows.", first.getValue() | ||
); | ||
// If all exceptions are task-migrated, we would just throw the first one. | ||
throw first.getValue(); | ||
} | ||
|
||
if (!activeTasksToCreate.isEmpty()) { | ||
|
@@ -293,12 +300,11 @@ boolean tryToCompleteRestoration() { | |
* @throws TaskMigratedException if the task producer got fenced (EOS only) | ||
*/ | ||
void handleRevocation(final Collection<TopicPartition> revokedPartitions) { | ||
final Set<TaskId> revokedTasks = new HashSet<>(); | ||
final Set<TopicPartition> remainingPartitions = new HashSet<>(revokedPartitions); | ||
|
||
for (final Task task : tasks.values()) { | ||
if (remainingPartitions.containsAll(task.inputPartitions())) { | ||
revokedTasks.add(task.id()); | ||
task.suspend(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the logic here as we no longer throws before task suspend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I follow: we can still throw from inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that we do not throw if remaining partitions are not empty anymore. We could directly suspend a task here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. |
||
} | ||
remainingPartitions.removeAll(task.inputPartitions()); | ||
} | ||
|
@@ -308,11 +314,6 @@ void handleRevocation(final Collection<TopicPartition> revokedPartitions) { | |
"due to race condition of consumer detecting the heartbeat failure, or the tasks " + | ||
"have been cleaned up by the handleAssignment callback.", remainingPartitions); | ||
} | ||
|
||
for (final TaskId taskId : revokedTasks) { | ||
final Task task = tasks.get(taskId); | ||
task.suspend(); | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a logging to log the IO exception.