kamalcph commented on PR #21361: URL: https://github.com/apache/kafka/pull/21361#issuecomment-3809041483
Thanks for the PR, @jiafu1115. 1. We cannot delete the segments in-middle when the `maxTimestamp` of the candidate segment is less than the `retention.ms` and move the log-start-offset. This will break the deletion breach by retention time logic. In [UnifiedLog#deleteRetentionMsBreachedSegments](https://sourcegraph.com/github.com/apache/kafka/-/blob/storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java?L1973:17-1973:50), the segments are being scanned from the beginning of the log. We cannot expect that the maxTimestamp in the segments will increase monotonically. 2. This optimization can be applied only to the deletion breached by size logic and can be moved to UnifiedLog. Similar to the `DELETE_RECORDS` API, that moves the log-start-offset. The segment deletion logic due to breach by size can increment the log-start-offset instead of local-log-start-offset when the `local-log-size > complete-retention` time. See [UnifiedLog](https://sourcegraph.com/github.com/apache/kafka/-/blob/storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java?L1927) for more details. -- 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]
