sunm2n opened a new pull request, #24381: URL: https://github.com/apache/kafka/pull/24381
A new share group's first assignor run happens on the first heartbeat, before the group's share partitions are initialized, so it computes an empty assignment. The partitions are only assigned by a later run. That run needs another heartbeat to start it, has to wait for the assignment interval that started with the empty assignment, and with offloading its result only reaches the member on the following heartbeat. In a local run with the default configuration, the member of a new group received its partitions on its fourth heartbeat, about 10 seconds after joining. This patch skips the assignor run when a share group has no target assignment and none of its share partitions are initialized. No assignment timestamp is recorded, so the assignment interval does not delay the first assignment. `initializeShareGroupState` then schedules a timer that starts the target assignment update once the initialization records have been replayed, without waiting for another heartbeat. The usual checks for an in-flight run and for the assignment interval still apply. To start an update without a member, the share group `maybeUpdateTargetAssignment` takes the member as an `Optional`, as the streams group version does. With the patch, the member in the same setup received its partitions on its second heartbeat, about 100 ms after joining. If initialization finishes after the second heartbeat, it still starts the assignment update without waiting for the third. The ticket proposed bumping the group epoch on initialization. This is not needed: the join already bumped it, and since the first run is skipped the assignment epoch stays behind, so the update started by the timer computes the assignment for that epoch. Until the first target assignment is installed, the members of the group stay at the initial assignment epoch and `ShareGroupDescribe` reports that epoch. This includes a group whose subscribed topics do not exist yet. If the assignment for the current group epoch is already installed when further share partitions are initialized, the timer does nothing. The next heartbeat detects the unassigned partitions and bumps the group epoch, as before. The subscription change sequence described in `ShareConsumerCallbackTest.testAcknowledgementSentOnSubscriptionChange`, which the ticket cites, can therefore still occur. The new unit tests cover initialization finishing before and after the member's next heartbeat, with offloading enabled and the default assignment interval. -- 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]
