KAFKA-17407: Fix flaky ShareGroupHeartbeatRequestTest.testPartitionAssignmentWithChangingTopics
Jira: https://issues.apache.org/jira/browse/KAFKA-17407 In my opinion, the old test run twice in https://github.com/apache/kafka/blob/4a485ddb71c844acc8bf241feda1fcbffc5ce9be/core/src/test/scala/unit/kafka/server/ShareGroupHeartbeatRequestTest.scala#L460 and make the epoch plus twice is wired. I find the reponse like, it means the hearbeat doen't get the right data at the first time
shareGroupHeartbeatResponses:
ShareGroupHeartbeatResponseData(
throttleTimeMs=0,
errorCode=0,
errorMessage=null,
memberId='9k-Z78-hQrClozREJ3LLXw',
memberEpoch=2,
heartbeatIntervalMs=500,
assignment=Assignment(
topicPartitions=[
TopicPartitions(
topicId=jU420_8ETCefApr4z8PDHQ,
partitions=[0, 1]
)
]
)
)
shareGroupHeartbeatResponses:
ShareGroupHeartbeatResponseData(
throttleTimeMs=0,
errorCode=0,
errorMessage=null,
memberId='9k-Z78-hQrClozREJ3LLXw',
memberEpoch=3,
heartbeatIntervalMs=500,
assignment=Assignment(
topicPartitions=[
TopicPartitions(
topicId=jU420_8ETCefApr4z8PDHQ,
partitions=[0, 1]
),
TopicPartitions(
topicId=RWmPmQI-R3azvx2lQBhKEQ,
partitions=[0, 1, 2]
)
]
)
)
I think the root cause is
https://github.com/apache/kafka/blob/4a485ddb71c844acc8bf241feda1fcbffc5ce9be/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java#L2197
https://github.com/apache/kafka/blob/4a485ddb71c844acc8bf241feda1fcbffc5ce9be/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java#L2178
It seen need some time to update the updatedMember variable, thus I make the thread to sleep 1s.
Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)