-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-16371: fix lingering pending commit when handling OFFSET_METADATA_TOO_LARGE #15536
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1661,6 +1661,65 @@ class GroupMetadataManagerTest { | |
assertEquals(0, TestUtils.totalMetricValue(metrics, "offset-commit-count")) | ||
} | ||
|
||
@Test | ||
def testOffsetMetadataTooLargePartialFailure(): Unit = { | ||
val memberId = "" | ||
val topicIdPartition = new TopicIdPartition(Uuid.randomUuid(), 0, "foo") | ||
val validTopicIdPartition = new TopicIdPartition(topicIdPartition.topicId, 1, "foo") | ||
val offset = 37 | ||
val requireStable = true; | ||
|
||
groupMetadataManager.addOwnedPartition(groupPartitionId) | ||
val group = new GroupMetadata(groupId, Empty, time) | ||
groupMetadataManager.addGroup(group) | ||
|
||
val offsetTopicPartition = new TopicPartition(Topic.GROUP_METADATA_TOPIC_NAME, groupMetadataManager.partitionFor(group.groupId)) | ||
val offsets = immutable.Map( | ||
topicIdPartition -> OffsetAndMetadata(offset, "s" * (offsetConfig.maxMetadataSize + 1) , time.milliseconds()), | ||
validTopicIdPartition -> OffsetAndMetadata(offset, "", time.milliseconds())) | ||
|
||
expectAppendMessage(Errors.NONE) | ||
|
||
var commitErrors: Option[immutable.Map[TopicIdPartition, Errors]] = None | ||
def callback(errors: immutable.Map[TopicIdPartition, Errors]): Unit = { | ||
commitErrors = Some(errors) | ||
} | ||
|
||
assertEquals(0, TestUtils.totalMetricValue(metrics, "offset-commit-count")) | ||
groupMetadataManager.storeOffsets(group, memberId, offsetTopicPartition, offsets, callback, verificationGuard = None) | ||
assertTrue(group.hasOffsets) | ||
|
||
assertFalse(commitErrors.isEmpty) | ||
assertEquals( | ||
Some(Errors.OFFSET_METADATA_TOO_LARGE), | ||
commitErrors.get.get(topicIdPartition) | ||
) | ||
assertEquals( | ||
Some(Errors.NONE), | ||
commitErrors.get.get(validTopicIdPartition) | ||
) | ||
Comment on lines
+1693
to
+1700
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Would it be possible to use |
||
|
||
val cachedOffsets = groupMetadataManager.getOffsets( | ||
groupId, | ||
requireStable, | ||
Some(Seq(topicIdPartition.topicPartition, validTopicIdPartition.topicPartition)) | ||
) | ||
assertEquals( | ||
Some(OffsetFetchResponse.INVALID_OFFSET), | ||
cachedOffsets.get(topicIdPartition.topicPartition).map(_.offset) | ||
) | ||
assertEquals( | ||
Some(Errors.NONE), | ||
cachedOffsets.get(topicIdPartition.topicPartition).map(_.error) | ||
) | ||
assertEquals( | ||
Some(offset), | ||
cachedOffsets.get(validTopicIdPartition.topicPartition).map(_.offset) | ||
) | ||
Comment on lines
+1707
to
+1718
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Same comment as the previous one. |
||
|
||
assertEquals(1, TestUtils.totalMetricValue(metrics, "offset-commit-count")) | ||
} | ||
|
||
@Test | ||
def testExpireOffset(): Unit = { | ||
val memberId = "" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could you put the last closing parenthesis on a new line? It would better with the style of the rest of the code in this file.