jolshan commented on a change in pull request #9944: URL: https://github.com/apache/kafka/pull/9944#discussion_r572373623
########## File path: core/src/main/scala/kafka/server/FetchSession.scala ########## @@ -425,16 +598,26 @@ class IncrementalFetchContext(private val time: Time, val topicPart = element.getKey val respData = element.getValue val cachedPart = session.partitionMap.find(new CachedPartition(topicPart)) - val mustRespond = cachedPart.maybeUpdateResponseData(respData, updateFetchContextAndRemoveUnselected) - if (mustRespond) { + + if (cachedPart.topicId == Uuid.ZERO_UUID) + cachedPart.addId(topicIds.getOrDefault(topicPart.topic, Uuid.ZERO_UUID)) + + if (cachedPart.topicId != topicIds.getOrDefault(topicPart.topic, Uuid.ZERO_UUID)) { nextElement = element - if (updateFetchContextAndRemoveUnselected) { - session.partitionMap.remove(cachedPart) - session.partitionMap.mustAdd(cachedPart) - } + session.partitionMap.remove(cachedPart) + iter.remove() Review comment: If we run into this scenario, does it make sense to always return with an UNKNOWN_TOPIC_ID error? Sometimes partitions will be skipped over anyway when `mustRespond` is false, so should those also return UNKNOWN_TOPIC_ID? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org