Skip to content
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

added guard for tombstone records in consumer_offset topic #644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 41 additions & 38 deletions app/kafka/manager/actor/cluster/KafkaStateActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -344,47 +344,50 @@ case class KafkaManagedOffsetCache(clusterContext: ClusterContext
val iterator = records.iterator()
while (iterator.hasNext) {
val record = iterator.next()
readMessageKey(ByteBuffer.wrap(record.key())) match {
case OffsetKey(version, key) =>
val value: OffsetAndMetadata = readOffsetMessageValue(ByteBuffer.wrap(record.value()))
val newKey = (key.group, key.topicPartition.topic, key.topicPartition.partition)
groupTopicPartitionOffsetMap.put(newKey, value)
groupTopicPartitionOffsetSet.add(newKey)
val topic = key.topicPartition.topic
val group = key.group
val consumerSet = {
if (topicConsumerSetMap.contains(topic)) {
topicConsumerSetMap(topic)
} else {
val s = new mutable.TreeSet[String]()
topicConsumerSetMap += topic -> s
s
}
}
consumerSet += group

val topicSet = {
if (consumerTopicSetMap.contains(group)) {
consumerTopicSetMap(group)
} else {
val s = new mutable.TreeSet[String]()
consumerTopicSetMap += group -> s
s
if(record.value()!=null) {
readMessageKey(ByteBuffer.wrap(record.key())) match {
case OffsetKey(version, key) =>
val value: OffsetAndMetadata = readOffsetMessageValue(ByteBuffer.wrap(record.value()))
val newKey = (key.group, key.topicPartition.topic, key.topicPartition.partition)
groupTopicPartitionOffsetMap.put(newKey, value)
groupTopicPartitionOffsetSet.add(newKey)
val topic = key.topicPartition.topic
val group = key.group
val consumerSet = {
if (topicConsumerSetMap.contains(topic)) {
topicConsumerSetMap(topic)
} else {
val s = new mutable.TreeSet[String]()
topicConsumerSetMap += topic -> s
s
}
}
}
topicSet += topic
case GroupMetadataKey(version, key) =>
val value: GroupMetadata = readGroupMessageValue(key, ByteBuffer.wrap(record.value()), Time.SYSTEM)
value.allMemberMetadata.foreach {
mm =>
mm.assignment.foreach {
case (topic, part) =>
val newKey = (key, topic, part)
groupTopicPartitionMemberMap.put(newKey, mm)
groupTopicPartitionMemberSet.add(newKey)
consumerSet += group

val topicSet = {
if (consumerTopicSetMap.contains(group)) {
consumerTopicSetMap(group)
} else {
val s = new mutable.TreeSet[String]()
consumerTopicSetMap += group -> s
s
}
}
}
topicSet += topic
case GroupMetadataKey(version, key) =>
val value: GroupMetadata = readGroupMessageValue(key, ByteBuffer.wrap(record.value()), Time.SYSTEM)
value.allMemberMetadata.foreach {
mm =>
mm.assignment.foreach {
case (topic, part) =>
val newKey = (key, topic, part)
groupTopicPartitionMemberMap.put(newKey, mm)
groupTopicPartitionMemberSet.add(newKey)
}
}
}
}

}
lastUpdateTimeMillis = System.currentTimeMillis()
} catch {
Expand Down