smjn commented on PR #22662:
URL: https://github.com/apache/kafka/pull/22662#issuecomment-4790306405

   > > This is incorrect as the API (KafkaApis.handleProduceRequest) will
   > > only look at the last entry per
   > > partition
   > > ignoring (0, [a,b,c]).
   > 
   > @smjn Can you please point me to faulty code in KafkaApis, sounds really 
strange that things are missing in KafkaApis library for produce request.
   
   @apoorvmittal10 
   
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/server/KafkaApis.scala#L448
   
   - Lines 417–432 flatten the request's partitionData into the 
topicIdToPartitionData ArrayBuffer — this preserves both duplicate entries 
(append-only buffer). So duplicates survive this stage.
   - Then 436–453 fold that buffer into `authorizedRequestInfo`, a 
`mutable.Map[TopicIdPartition, MemoryRecords]`. The key is `TopicIdPartition = 
(topicId, TopicPartition(name, partition.index()))`. Two `PartitionProduceData` 
with the same partition index → identical key → the second += overwrites the 
first (Scala mutable map += is put/replace). So only the last handler's 
`MemoryRecords` for that partition remains.


-- 
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]

Reply via email to