skaundinya15 commented on a change in pull request #8850: URL: https://github.com/apache/kafka/pull/8850#discussion_r438573463
########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -1784,8 +1784,18 @@ class Log(@volatile private var _dir: File, private def deleteRetentionMsBreachedSegments(): Int = { if (config.retentionMs < 0) return 0 val startMs = time.milliseconds - deleteOldSegments((segment, _) => startMs - segment.largestTimestamp > config.retentionMs, - reason = s"retention time ${config.retentionMs}ms breach") + + def shouldDelete(segment: LogSegment, nextSegmentOpt: Option[LogSegment]) = { + if (startMs - segment.largestTimestamp > config.retentionMs) { + info(s"Segment with base offset ${segment.baseOffset} will be deleted due to" + + s" retentionMs breach. Largest timestamp of segment is ${segment.largestTimestamp}") + true + } else { + false + } + } + + deleteOldSegments(shouldDelete, reason = s"retention time ${config.retentionMs}ms breach") Review comment: Yeah I agree, I think it would be redundant to keep the `reason` in `deleteOldSegments`. I'll remove that and as you suggested just mentioned the number of segments getting deleted. ---------------------------------------------------------------- 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