chia7712 commented on code in PR #22873:
URL: https://github.com/apache/kafka/pull/22873#discussion_r3931564987
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java:
##########
@@ -2005,34 +2005,30 @@ private int deleteRetentionMsBreachedSegments() throws
IOException {
long startMs = time().milliseconds();
DeletionCondition shouldDelete = (segment, nextSegmentOpt) -> {
- if (startMs < segment.largestTimestamp()) {
- futureTimestampLogger.warn("{} contains future timestamp(s),
making it ineligible to be deleted", segment);
+ long anchorTimestamp = segment.largestTimestamp();
+ if (startMs < anchorTimestamp) {
+ if (remoteLogEnabledAndRemoteCopyEnabled()) {
+ anchorTimestamp = segment.lastModified();
+ futureTimestampLogger.warn("{} contains future
timestamp(s), using lastModified time {} as the retention anchor", segment,
anchorTimestamp);
+ } else {
+ futureTimestampLogger.warn("{} contains future
timestamp(s), making it ineligible to be deleted", segment);
+ }
}
- boolean delete = startMs - segment.largestTimestamp() >
retentionMs;
+ boolean delete = startMs - anchorTimestamp > retentionMs;
logger.debug("{} retentionMs breached: {}, startMs={},
retentionMs={}",
segment, delete, startMs, retentionMs);
return delete;
};
return deleteOldSegments(shouldDelete, toDelete -> {
- long localRetentionMs = UnifiedLog.localRetentionMs(config(),
remoteLogEnabledAndRemoteCopyEnabled());
+ boolean remoteCopyEnabled = remoteLogEnabledAndRemoteCopyEnabled();
+ long localRetentionMs = UnifiedLog.localRetentionMs(config(),
remoteCopyEnabled);
Review Comment:
`localRetentionMs` is duplicate to `retentionMs`, right?
--
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]