Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-14 Thread via GitHub


lucasbru merged PR #20755:
URL: https://github.com/apache/kafka/pull/20755


-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-12 Thread via GitHub


lucasbru commented on PR #20755:
URL: https://github.com/apache/kafka/pull/20755#issuecomment-3521147372

   @RaidenE1 This needs a rebase. And I think because this is affecting so many 
tests, we probably should run the system tests that have KIP-1071 enabled.


-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-10 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2502973677


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8182,6 +8182,7 @@ public void createGroupTombstoneRecords(
 ) {
 // At this point, we have already validated the group id, so we know 
that the group exists and that no exception will be thrown.
 createGroupTombstoneRecords(group(groupId), records);
+timer.cancel(streamsInitialRebalanceKey(groupId));

Review Comment:
   This is already executed in the line above.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##


Review Comment:
   createGroupTombstoneRecordsAndCancelTimers



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8195,6 +8196,7 @@ public void createGroupTombstoneRecords(
 List records
 ) {
 group.createGroupTombstoneRecords(records);
+timer.cancel(streamsInitialRebalanceKey(group.groupId()));

Review Comment:
   Other timers are cancelled using a dedicated cancel function like this:
   
   ```
   /**
* Cancels the sync timeout of the member.
*
* @param groupId   The group id.
* @param memberId  The member id.
*/
   private void cancelConsumerGroupSyncTimeout(
   String groupId,
   String memberId
   ) {
   timer.cancel(consumerGroupSyncKey(groupId, memberId));
   }
   ```
   
   Best to follow that pattern.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##


Review Comment:
   createGroupTombstoneRecordsAndCancelTimers ? 



-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-06 Thread via GitHub


squah-confluent commented on PR #20755:
URL: https://github.com/apache/kafka/pull/20755#issuecomment-3498533647

   Thanks for the PR!
   
   The interaction with delayed assignments would be fine. The initial 
rebalance delay would be just another condition to take into account when 
deciding whether to start an assignment run.
   
   The timer usage looks fine. We're missing some cleanup as @lucasbru pointed 
out.


-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-06 Thread via GitHub


squah-confluent commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2500045819


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8570,6 +8645,8 @@ private boolean maybeDeleteEmptyStreamsGroup(String 
groupId, List

Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-05 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2495931755


##
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##
@@ -17371,14 +17377,89 @@ public void 
testStreamsGroupHeartbeatPartialResponseWhenNothingChanges() {
 .setMemberId(memberId)
 .setMemberEpoch(result.response().data().memberEpoch()));
 
+assertResponseEquals(
+new StreamsGroupHeartbeatResponseData()
+.setMemberId(memberId)
+.setMemberEpoch(2)
+.setHeartbeatIntervalMs(5000)
+.setEndpointInformationEpoch(-1),
+result.response().data()
+);
+}
+
+@Test
+public void 
testStreamsInitialRebalanceDelay_EmptyDuringDelay_AssignsAfterTimer() {

Review Comment:
   I don't think we put underscores in the tests in this files



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -3976,8 +4003,11 @@ private TasksTuple updateStreamsTargetAssignment(
 .withTopology(configuredTopology)
 .withStaticMembers(group.staticMembers())
 .withMetadataImage(metadataImage)
-.withTargetAssignment(group.targetAssignment())
-.addOrUpdateMember(updatedMember.memberId(), updatedMember);
+.withTargetAssignment(group.targetAssignment());
+
+if (updatedMember.isPresent()) {

Review Comment:
   Could this use updatedMember.ifPresent(() => ...)?



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -3994,7 +4024,7 @@ private TasksTuple updateStreamsTargetAssignment(
 
 records.addAll(assignmentResult.records());
 
-return 
assignmentResult.targetAssignment().get(updatedMember.memberId());
+return updatedMember.isPresent() ? 
assignmentResult.targetAssignment().get(updatedMember.get().memberId()) : 
TasksTuple.EMPTY;

Review Comment:
   map(..).orElse(...)?



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,57 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+int initialGroupEpoch = groupEpoch;
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (groupEpoch == 0) {
+groupEpoch = 2;
+} else {
+groupEpoch += 1;
+}
 records.add(newStreamsGroupMetadataRecord(groupId, groupEpoch, 
metadataHash, validatedTopologyEpoch, currentAssignmentConfigs));
 log.info("[GroupId {}][MemberId {}] Bumped streams group epoch to 
{} with metadata hash {} and validated topic epoch {}.", groupId, memberId, 
groupEpoch, metadataHash, validatedTopologyEpoch);
 metrics.record(STREAMS_GROUP_REBALANCES_SENSOR_NAME);
 group.setMetadataRefreshDeadline(currentTimeMs + 
METADATA_REFRESH_INTERVAL_MS, groupEpoch);
 }
 
+// Schedule initial rebalance delay for new streams groups to coalesce 
joins.
+boolean isInitialRebalance = (initialGroupEpoch == 0);

Review Comment:
   could we just use `group.groupEpoch()` here?



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8570,6 +8645,8 @@ private boolean maybeDeleteEmptyStreamsGroup(String 
groupId, List

Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-04 Thread via GitHub


RaidenE1 commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2490881541


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -3693,7 +3717,7 @@ private StreamsGroupMember maybeReconcile(
 List ownedWarmupTasks,
 List records
 ) {
-if (member.isReconciledTo(targetAssignmentEpoch)) {
+if (member.isReconciledTo(targetAssignmentEpoch) && 
member.assignedTasks().equals(targetAssignment)) {

Review Comment:
   Forget to revert it



-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-11-04 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2489901598


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/CurrentAssignmentBuilder.java:
##
@@ -161,7 +161,9 @@ public StreamsGroupMember build() {
 case STABLE:
 // When the member is in the STABLE state, we verify if a newer
 // epoch (or target assignment) is available. If it is, we can
-// reconcile the member towards it. Otherwise, we return.
+// reconcile the member towards it. If the epoch is the same 
but
+// the target assignment has changed (e.g., after initial 
rebalance
+// delay fires), we must still reconcile to propagate the new 
tasks.

Review Comment:
   Is this comment update accurate? I don't understand it. If the epoch is the 
same, the target asiggnment should be the same.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (bumpGroupEpoch && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (groupEpoch == 0) {
+groupEpoch += 2;
+} else {
+groupEpoch += 1;
+}
 records.add(newStreamsGroupMetadataRecord(groupId, groupEpoch, 
metadataHash, validatedTopologyEpoch, currentAssignmentConfigs));
 log.info("[GroupId {}][MemberId {}] Bumped streams group epoch to 
{} with metadata hash {} and validated topic epoch {}.", groupId, memberId, 
groupEpoch, metadataHash, validatedTopologyEpoch);
 metrics.record(STREAMS_GROUP_REBALANCES_SENSOR_NAME);
 group.setMetadataRefreshDeadline(currentTimeMs + 
METADATA_REFRESH_INTERVAL_MS, groupEpoch);
 }
 
+// Schedule initial rebalance delay for new streams groups to coalesce 
joins.
+int initialDelayMs = streamsGroupInitialRebalanceDelayMs(groupId);

Review Comment:
   Maybe we can only read the configuration if `inInitialRebalance == true`



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -4003,6 +4027,69 @@ private TasksTuple updateStreamsTargetAssignment(
 }
 }
 
+/**
+ * Fires the initial rebalance for a streams group when the delay timer 
expires.
+ * Computes and persists target assignment for all members if conditions 
are met.
+ *
+ * @param groupId The group id.
+ * @return A CoordinatorResult with records to persist the target 
assignment, or EMPTY_RESULT.
+ */
+private CoordinatorResult 
fireStreamsInitialRebalance(
+String groupId
+) {
+try {
+StreamsGroup group = streamsGroup(groupId);
+
+if (group.groupEpoch() <= group.assignmentEpoch()) {

Review Comment:
   This case should not be possible, so I'd throw an IllegalStateException in 
this case.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (bumpGroupEpoch && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (groupEpoch == 0) {
+groupEpoch += 2;

Review Comment:
   This could be `groupEpoch = 2`



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (bumpGroupEpoch && groupEpoch == 0);

Review Comment:
   Do we really need to check `bumpGroupEpoch` here? We should only get here 
with `groupEpoch == 0` once, and the `bumpGroupEpoch` should be implied.
   
   I would also move this variable further down to where it is used.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8570,6 +8657,10 @@ private boolean maybeDeleteEmptyStreamsGroup(String 
groupId, List 
fireStreamsInitialRebalance(

Review Comment:
   `computeDelayedTargetAssignment`?



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroupMember.java:
##
@@ -288,6 +288,7 @@ public static Builder withDefaults(String memberId) {
 .setClientTags(Collections.emptyMap())
 .setState(MemberState.STABLE)
 .setMemberEpoch(0)
+.setPreviousMemberEpoch(0)

Review Comment:
   Do we 

Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-30 Thread via GitHub


Copilot commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r247902


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (bumpGroupEpoch && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (groupEpoch == 0) {
+groupEpoch += 2;
+} else {
+groupEpoch += 1;
+}
 records.add(newStreamsGroupMetadataRecord(groupId, groupEpoch, 
metadataHash, validatedTopologyEpoch, currentAssignmentConfigs));
 log.info("[GroupId {}][MemberId {}] Bumped streams group epoch to 
{} with metadata hash {} and validated topic epoch {}.", groupId, memberId, 
groupEpoch, metadataHash, validatedTopologyEpoch);
 metrics.record(STREAMS_GROUP_REBALANCES_SENSOR_NAME);
 group.setMetadataRefreshDeadline(currentTimeMs + 
METADATA_REFRESH_INTERVAL_MS, groupEpoch);
 }
 
+// Schedule initial rebalance delay for new streams groups to coalesce 
joins.
+int initialDelayMs = streamsGroupInitialRebalanceDelayMs(groupId);
+if (isInitialRebalance && initialDelayMs > 0) {
+timer.scheduleIfAbsent(
+streamsInitialRebalanceKey(groupId),
+initialDelayMs,
+TimeUnit.MILLISECONDS,
+false,
+() -> fireStreamsInitialRebalance(groupId)
+);
+}
+
 // 4. Update the target assignment if the group epoch is larger than 
the target assignment epoch or a static member
 // replaces an existing static member.
 // The delta between the existing and the new target assignment is 
persisted to the partition.
 int targetAssignmentEpoch;
 TasksTuple targetAssignment;
 if (groupEpoch > group.assignmentEpoch()) {
-targetAssignment = updateStreamsTargetAssignment(
-group,
-groupEpoch,
-updatedMember,
-updatedConfiguredTopology,
-metadataImage,
-records,
-currentAssignmentConfigs
-);
-targetAssignmentEpoch = groupEpoch;
+boolean initialDelayActive = 
timer.isScheduled(streamsInitialRebalanceKey(groupId));

Review Comment:
   The condition `group.assignmentEpoch() == 0` is checked here, but the timer 
is scheduled when `isInitialRebalance` is true (line 2003), which depends on 
`groupEpoch == 0` before bumping. Consider adding a comment explaining why we 
check `assignmentEpoch()` here instead of checking if the timer is scheduled 
for a more explicit relationship between these conditions.
   ```suggestion
   boolean initialDelayActive = 
timer.isScheduled(streamsInitialRebalanceKey(groupId));
   // Note: We check group.assignmentEpoch() == 0 here instead of 
whether the timer is scheduled,
   // because the timer for the initial rebalance is scheduled when 
isInitialRebalance is true,
   // which depends on groupEpoch == 0 before bumping. 
assignmentEpoch() == 0 indicates that the
   // group has not yet performed an assignment, which is the 
relevant state for returning an
   // empty assignment during the initial rebalance delay.
   ```



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8716,6 +8816,20 @@ static String classicGroupSyncKey(String groupId) {
 return "sync-" + groupId;
 }
 
+
+/**
+ * Generate a streams group initial rebalance key for the timer.
+ *
+ * Package private for testing.
+ *
+ * @param groupId   The group id.
+ *
+ * @return the initial rebalance key.
+ */
+static String streamsInitialRebalanceKey(String groupId) {
+return "initial-rebalance-timeout-" + groupId;
+}

Review Comment:
   [nitpick] There's an extra blank line (8819) before the Javadoc comment. 
This is inconsistent with other methods in the class and should be removed for 
consistency.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (bumpGroupEpoch && groupEpoch == 0);

Review Comment:
   The `isInitialRebalance` flag is computed before `groupEpoch` is potentially 
modified (lines 1990-1994). However, the variable name and its usage suggest it 
should represent whether this is the initial rebalance. Consider computing this 
flag after the 

Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-29 Thread via GitHub


Copilot commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2474176821


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (group.isEmpty() && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (isInitialRebalance) {
+groupEpoch += 2;
+} else {
+groupEpoch += 1;
+}

Review Comment:
   The `isInitialRebalance` check on line 1988 is evaluated before 
`bumpGroupEpoch` is processed (line 1989-1999), but the condition relies on 
`group.isEmpty()` which becomes false after the member is added to the group 
earlier in the method. This means `isInitialRebalance` will always be false for 
the first member join since the member is already added to the group before 
this check. The timer scheduling on line 2003 may never execute as intended.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (group.isEmpty() && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (isInitialRebalance) {
+groupEpoch += 2;
+} else {
+groupEpoch += 1;
+}
 records.add(newStreamsGroupMetadataRecord(groupId, groupEpoch, 
metadataHash, validatedTopologyEpoch, currentAssignmentConfigs));
 log.info("[GroupId {}][MemberId {}] Bumped streams group epoch to 
{} with metadata hash {} and validated topic epoch {}.", groupId, memberId, 
groupEpoch, metadataHash, validatedTopologyEpoch);
 metrics.record(STREAMS_GROUP_REBALANCES_SENSOR_NAME);
 group.setMetadataRefreshDeadline(currentTimeMs + 
METADATA_REFRESH_INTERVAL_MS, groupEpoch);
 }
 
+// Schedule initial rebalance delay for new streams groups to coalesce 
joins.
+int initialDelayMs = streamsGroupInitialRebalanceDelayMs(groupId);
+if (isInitialRebalance && initialDelayMs > 0) {

Review Comment:
   The `isInitialRebalance` check on line 1988 is evaluated before 
`bumpGroupEpoch` is processed (line 1989-1999), but the condition relies on 
`group.isEmpty()` which becomes false after the member is added to the group 
earlier in the method. This means `isInitialRebalance` will always be false for 
the first member join since the member is already added to the group before 
this check. The timer scheduling on line 2003 may never execute as intended.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = (group.isEmpty() && groupEpoch == 0);
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (isInitialRebalance) {
+groupEpoch += 2;
+} else {
+groupEpoch += 1;
+}
 records.add(newStreamsGroupMetadataRecord(groupId, groupEpoch, 
metadataHash, validatedTopologyEpoch, currentAssignmentConfigs));
 log.info("[GroupId {}][MemberId {}] Bumped streams group epoch to 
{} with metadata hash {} and validated topic epoch {}.", groupId, memberId, 
groupEpoch, metadataHash, validatedTopologyEpoch);
 metrics.record(STREAMS_GROUP_REBALANCES_SENSOR_NAME);
 group.setMetadataRefreshDeadline(currentTimeMs + 
METADATA_REFRESH_INTERVAL_MS, groupEpoch);
 }
 
+// Schedule initial rebalance delay for new streams groups to coalesce 
joins.
+int initialDelayMs = streamsGroupInitialRebalanceDelayMs(groupId);
+if (isInitialRebalance && initialDelayMs > 0) {
+timer.scheduleIfAbsent(
+streamsInitialRebalanceKey(groupId),
+initialDelayMs,
+TimeUnit.MILLISECONDS,
+false,
+() -> fireStreamsInitialRebalance(groupId)
+);
+}

Review Comment:
   The timer is only scheduled when `bumpGroupEpoch` is true (due to placement 
after line 1999), but `isInitialRebalance` is checked independently. If the 
first member join doesn't trigger a group epoch bump (which could happen if no 
metadata changes occur), the initial rebalance timer may not be scheduled. 
Consider scheduling the timer before the `bumpGroupEpoch` condition or ensuring 
it's always scheduled for the first member.



-- 
This is an automated 

Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-25 Thread via GitHub


mjsax commented on PR #20755:
URL: https://github.com/apache/kafka/pull/20755#issuecomment-3447875740

   Let's make sure we do not forget to update the docs, for the new config.


-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-24 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2460750375


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = group.isEmpty();
 if (bumpGroupEpoch) {
-groupEpoch += 1;
+if (isInitialRebalance) {
+groupEpoch = 2;

Review Comment:
   If the group becomes empty at epoch 9, we are going back in time here to 
epoch 2, right?



-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-24 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2460748619


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -1985,30 +1985,54 @@ private CoordinatorResult stream
 
 // Actually bump the group epoch
 int groupEpoch = group.groupEpoch();
+boolean isInitialRebalance = group.isEmpty();

Review Comment:
   Group being empty does not mean initial rebalance right? It could be that 
the group became empty again?



-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-24 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2460744533


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##
@@ -8716,6 +8753,31 @@ static String classicGroupSyncKey(String groupId) {
 return "sync-" + groupId;
 }
 
+/**
+ * Callback when the initial rebalance delay timer expires.
+ * This is a no-op as the actual assignment computation happens on the 
next heartbeat.
+ *
+ * @param groupId   The group id.
+ *
+ * @return An empty result.
+ */
+private CoordinatorResult 
fireStreamsInitialRebalance(String groupId) {

Review Comment:
   If this is not doing anything, I think we can inline this.



-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-23 Thread via GitHub


RaidenE1 commented on PR #20755:
URL: https://github.com/apache/kafka/pull/20755#issuecomment-3437201704

   @lucasbru Hi Lucas, I'm not going to merge it now, I'll add more things to 
it. Just want you to take a quick look to make sure I'm on the right direction!
   
   
   
   
   
   


-- 
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]



Re: [PR] KAFKA-19829: Implement group-level initial rebalance delay [kafka]

2025-10-23 Thread via GitHub


lucasbru commented on code in PR #20755:
URL: https://github.com/apache/kafka/pull/20755#discussion_r2454986110


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##
@@ -290,6 +290,10 @@ public class GroupCoordinatorConfig {
 public static final int STREAMS_GROUP_MAX_STANDBY_REPLICAS_DEFAULT = 2;
 public static final String STREAMS_GROUP_MAX_STANDBY_REPLICAS_DOC = "The 
maximum allowed value for the group-level configuration of " + 
GroupConfig.STREAMS_NUM_STANDBY_REPLICAS_CONFIG;
 
+public static final String STREAMS_GROUP_INITIAL_REBALANCE_DELAY_MS_CONFIG 
= "group.streams.initial.rebalance.delay.ms";
+public static final int STREAMS_GROUP_INITIAL_REBALANCE_DELAY_MS_DEFAULT = 
3000;

Review Comment:
   @mjsax Are we good with a default of 3 seconds for delaying the initial 
rebalance?



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##
@@ -961,4 +968,11 @@ public int streamsGroupNumStandbyReplicas() {
 public int streamsGroupMaxNumStandbyReplicas() {
 return streamsGroupMaxStandbyReplicas;
 }
+
+/**
+ * The initial rebalance delay for streams groups.
+ */
+public int streamsGroupInitialRebalanceDelayMs() {

Review Comment:
   I would not introduce completely unused things in PRs. It may be better to 
extend this PR to actually make use of the configuration



-- 
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]