mjsax commented on code in PR #20833:
URL: https://github.com/apache/kafka/pull/20833#discussion_r2525555491
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignor.java:
##########
@@ -1458,6 +1458,14 @@ protected boolean maybeUpdateSubscriptionVersion(final
int receivedAssignmentMet
@Override
public void onAssignment(final Assignment assignment, final
ConsumerGroupMetadata metadata) {
+ final Set<Task> tasksWithOpenTransactions = taskManager.allOwnedTasks()
+ .values()
+ .stream()
+ .filter(t -> t.commitNeeded())
+ .collect(Collectors.toSet());
+ log.info("Committing {} tasks with open transactions before
onAssignment()", tasksWithOpenTransactions.size());
+ taskManager.commit(tasksWithOpenTransactions);
Review Comment:
Thank Lianet.
Atm, the KS code is not setup to handle an exception bubbling out of
`poll()`. It would crash the whole `StreamsThreads`.
Also, if we fail here, we would not executed any of the assignment logic, so
we need to make sure we don't get into corrupted internal state when we exit
`onAssignment` with an error, w/o completing the assignment logic. Of course,
if we let the thread crash, nothing to worry about 😂 -- but if we don't want to
let `StreamsThread` just crash, we need to be very careful how to handle it.
The question is: if we cannot commit, do we really need to do an "abort
everything" -- might depend on the commit error, too. In general, for EOS when
a commit fails, many tasks are affected as we commit many tasks at ones, so a
larger cleanup is required.
--
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]