mjsax commented on code in PR #24166:
URL: https://github.com/apache/kafka/pull/24166#discussion_r4607951563
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroup.java:
##########
@@ -239,14 +239,20 @@ public static class DeadlineAndEpoch {
private final Map<String, MemberTaskOffsets> taskOffsets = new HashMap<>();
/**
- * 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.
+ * The version of the latest streams group heartbeat of each member, keyed
by member ID. 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.
*/
private final Map<String, Integer> heartbeatVersions = new HashMap<>();
+ /**
+ * The assignment epoch of the group when the coordinator loaded it, or -1
if the group was created after the load.
+ * The intermediate assignment of this epoch and of earlier ones was
derived by a previous coordinator and is lost,
+ * while members may already have reconciled to it.
Review Comment:
> The intermediate assignment of this and earlier epoch was derived by a
previous coordinator and is lost, while members may already have reconciled to
it.
Yes, but it doesn't explain the "why does this matter, and what does it
imply.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -4802,7 +4806,11 @@ private Map<String, TasksTuple>
refinedAssignmentForEpoch(
if (cached != null) {
return cached;
}
- final Map<String, TasksTuple> refinedAssignment =
refineAssignment(group, targetAssignment, configuredTopology);
+ // If the group had reached this epoch when the coordinator loaded it,
its intermediate assignment is lost, and
Review Comment:
```suggestion
// If the group's {@code assignmentEpoch} is not new, ie, smaller or
equal to the epoch when the coordinator loaded the group, its intermediate
assignment is lost, and
```
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefiner.java:
##########
@@ -75,6 +75,11 @@ public interface AssignmentRefiner {
* its restore progress cannot be observed and it could never be
promoted from warm-up to active. An
* implementation must not newly place a warm-up task on a member
that is not known to report them, but a
* member of unknown version may keep a warm-up task that its
process already holds.
+ * @param keepActiveTasks
+ * Whether every active task has to stay with the member that holds
it. The coordinator sets this when it
+ * derives the intermediate assignment again for an assignment
epoch that members may already have
+ * reconciled to, after it loaded the group. Within an epoch, a
member that has reconciled to it is told
+ * nothing new, so it would never release a task to another member.
Review Comment:
> The coordinator sets this when it derives the intermediate assignment
again for an assignment epoch that members may already have reconciled to,
after it loaded the group.
I find it weird to explain on a parameter how it's used... This is an odd
thing Claude often does (I have a local rule in my CLAUDE.md to prevent this).
If the caller code changes, we would need to update this description, and in
general, the parameter should only describe how it's used and how it tell the
callee to do, but no reason about when and why a caller would set a certain
value.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -540,6 +576,11 @@ static WarmupPlan planWarmups(
loadAfterGrants(processLoad, currentAssignment, decisions,
members);
final List<FundingCandidate> candidates = new ArrayList<>();
+ // 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. A sibling's
+ // standby task that would move onto the target owner is borrowed
where it sits instead, which costs no slot.
Review Comment:
```suggestion
// standby task that would move onto the target owner is borrowed
where it sits instead, which costs no warm-up slot.
```
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -4802,7 +4806,11 @@ private Map<String, TasksTuple>
refinedAssignmentForEpoch(
if (cached != null) {
return cached;
}
- final Map<String, TasksTuple> refinedAssignment =
refineAssignment(group, targetAssignment, configuredTopology);
+ // If the group had reached this epoch when the coordinator loaded it,
its intermediate assignment is lost, and
+ // members may already have reconciled to the epoch under it. They are
told nothing new within the epoch, so a
+ // member that holds an active task would never release it to another
member.
Review Comment:
> They are told nothing new within the epoch, so a member that holds an
active task would never release it to another member.
This sounds rather cryptic? How about:
`For this case, we cannot move any task to a new member, because the old
owner reached the epoch already and thus completed releasing tasks. Instead, we
need to wait for an epoch bump to be able to move tasks, ensuring that the old
owner releases the task correctly.`
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2315,7 +2315,7 @@ private CoordinatorResult<StreamsGroupHeartbeatResult,
CoordinatorRecord> stream
if (assignmentUpdate == AssignmentUpdate.NONE && group.state() ==
StreamsGroup.StreamsGroupState.STABLE) {
// We are not computing a new target assignment later, thus we try
to refine the current target assignment
// into an intermediate assignment (with warm-up tasks) the member
should be reconciled towards.
- refinedGroupAssignment = refineAssignment(group,
group.targetAssignment(), updatedConfiguredTopology);
+ refinedGroupAssignment = refineAssignment(group,
group.targetAssignment(), updatedConfiguredTopology, false);
Review Comment:
Maybe explain the hard coded `false`?
```
// If the intermediate assignment differs from the assigned tasks, it starts
a new epoch that every member reconciles to; otherwise it matches them. Either
way no active task needs to be kept.
```
--
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]