mjsax commented on code in PR #24166:
URL: https://github.com/apache/kafka/pull/24166#discussion_r4591807261
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -65,10 +65,12 @@ public Map<String, TasksTuple> refine(
final CurrentAssignmentIndex currentAssignment =
indexCurrentAssignment(members, taskOffsets, subtopologies,
acceptableRecoveryLag);
final Map<String, ProcessLoad> processLoad = indexProcessLoad(members,
subtopologies);
- final TaskDecisions decisions =
- analyzeTasks(currentAssignment, targetAssignment, members,
heartbeatVersions, subtopologies, processLoad);
- final WarmupPlan warmupPlan =
- planWarmups(decisions, currentAssignment, members, processLoad,
numWarmupReplicas);
+ final boolean everyMemberHeardFrom =
heartbeatVersions.keySet().containsAll(members.keySet());
+ final TaskDecisions decisions = analyzeTasks(
+ currentAssignment, targetAssignment, members, heartbeatVersions,
everyMemberHeardFrom, subtopologies,
+ processLoad);
Review Comment:
```suggestion
final TaskDecisions decisions = analyzeTasks(
currentAssignment,
targetAssignment,
members,
heartbeatVersions,
everyMemberHeardFrom,
subtopologies,
processLoad
);
```
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -305,6 +314,21 @@ static TaskDecisions analyzeTasks(
}
final String targetProcessId = targetMember.processId();
+
+ // Don't move an active task to another member until every member
has heartbeated. Moving a task needs its
+ // current owner to give it up. Right after a coordinator
failover, the current owner may already have
+ // reconciled to the current epoch, and is then sent nothing new
within that epoch. It would never give
+ // the task up, and the target owner would wait for it forever.
The move happens in the first epoch after
+ // every member has heartbeated.
+ if (holder != null && !everyMemberHeardFrom) {
Review Comment:
Seems `Don't move an active task to another member until every member has
heartbeated` does not describe this condition correctly? It only applies if a
task has a current owner, but not to orphaned tasks?
Or at least is might easily be misread?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -524,13 +551,19 @@ static WarmupPlan planWarmups(
final TaskDecisions decisions,
final CurrentAssignmentIndex currentAssignment,
final Map<String, StreamsGroupMember> members,
+ final boolean everyMemberHeardFrom,
final Map<String, ProcessLoad> processLoad,
final int numWarmupReplicas
) {
if (numWarmupReplicas == 0) {
return WarmupPlan.EMPTY;
}
+ // Fund no new warm-up task until every member has heartbeated after a
coordinator failover. Before that, the
+ // members' restore progress is unknown, so we can't tell which target
owner is best to warm up. We wait for all
+ // members, not only for the target owner, because a warm-up task
stays once placed: otherwise the members that
+ // heartbeat first would get the warm-up tasks. Warm-up tasks that
members already hold are kept.
Review Comment:
Should this comment go directly above the `switch (warming)` block?
It says `Warm-up tasks that members already hold are kept.` and `Fund no new
warm-up task until every member has heartbeated` what the code reflects. But
the code also make a sibling-move a borrowed-migration -- might be good to
explain why?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -65,10 +65,12 @@ public Map<String, TasksTuple> refine(
final CurrentAssignmentIndex currentAssignment =
indexCurrentAssignment(members, taskOffsets, subtopologies,
acceptableRecoveryLag);
final Map<String, ProcessLoad> processLoad = indexProcessLoad(members,
subtopologies);
- final TaskDecisions decisions =
- analyzeTasks(currentAssignment, targetAssignment, members,
heartbeatVersions, subtopologies, processLoad);
- final WarmupPlan warmupPlan =
- planWarmups(decisions, currentAssignment, members, processLoad,
numWarmupReplicas);
+ final boolean everyMemberHeardFrom =
heartbeatVersions.keySet().containsAll(members.keySet());
+ final TaskDecisions decisions = analyzeTasks(
+ currentAssignment, targetAssignment, members, heartbeatVersions,
everyMemberHeardFrom, subtopologies,
+ processLoad);
Review Comment:
Maybe same for `planWarmups(...)` call below?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroup.java:
##########
@@ -228,11 +228,16 @@ public static class DeadlineAndEpoch {
/**
* The version of the latest streams group heartbeat of each member, keyed
by member ID, which tells the
* {@link AssignmentRefiner} which members report their task offsets. A
member that is missing has not heartbeated
- * since the coordinator loaded the group. Like {@link #taskOffsets}, it
is transient: written in the heartbeat
- * path, dropped when the member is removed and lost on coordinator
failover. It is not persisted, so that it can
- * never outlive the client that sent it.
+ * since the coordinator loaded the group. It is written in the heartbeat
path, dropped when the member is removed
+ * and lost on coordinator failover. It is not persisted, so that it can
never outlive the client that sent it.
+ * <p>
+ * Unlike {@link #taskOffsets} it is kept in a timeline container, so that
a failed write that rolls back the
+ * removal of a member also brings back its version, and one that rolls
back a join drops it. A member of the group
+ * without a version holds back every move of an active task in the
refiner until it heartbeats. A rollback also
Review Comment:
> back every move of an active task
Yes, and also holds back new warmup placements. But should we document it
hear? The data structure itself does not know how it's used?
--
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]