junrao commented on code in PR #17193:
URL: https://github.com/apache/kafka/pull/17193#discussion_r1826381383


##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -774,7 +778,11 @@ private[log] class Cleaner(val id: Int,
         val batchRetention: BatchRetention =
           if (batch.hasProducerId && isBatchLastRecordOfProducer)
             BatchRetention.RETAIN_EMPTY
-          else if (discardBatchRecords)
+          else if (batch.nextOffset == upperBoundOffsetOfCleaningRound) {

Review Comment:
   @vincent81jiang : It seems that we could improve this a bit. Strictly 
speaking, we only need to preserve this batch if the nextOffset is the same as 
the high watermark. This will reduce the number of unnecessary empty batches.



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