gyang94 commented on code in PR #3222:
URL: https://github.com/apache/fluss/pull/3222#discussion_r3548981649


##########
fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java:
##########
@@ -1196,17 +1259,27 @@ private List<LogSegment> deletableSegments(long 
endOffset) {
         // readers is in progress.
         List<LogSegment> deletableSegments = new ArrayList<>();
         List<LogSegment> logSegments = localLog.getSegments().values();
-        // ignore the segments configured to be retained
-        for (int i = 0; i < logSegments.size() - tieredLogLocalSegments; i++) {
-            if (logSegments.get(i + 1).getBaseOffset() <= endOffset) {
-                deletableSegments.add(logSegments.get(i));
-            } else {
+        int tierProtectedStartIndex = logSegments.size() - 
tieredLogLocalSegments;
+        long now = clock.milliseconds();
+
+        for (int i = 0; i < logSegments.size() - 1; i++) {
+            if (logSegments.get(i + 1).getBaseOffset() > endOffset) {
                 break;
             }
+            if (i < tierProtectedStartIndex || isSegmentExpired(now, 
logSegments.get(i))) {
+                deletableSegments.add(logSegments.get(i));
+            }
         }
         return deletableSegments;
     }
 
+    private boolean isSegmentExpired(long now, LogSegment segment) throws 
IOException {
+        if (logTtlMs <= 0L) {
+            return false;
+        }
+        return now - segment.maxTimestampSoFar() > logTtlMs;
+    }

Review Comment:
   could we introduce a new config for rolling active segment? logTTL may be 
too long for rolling active segment. 
   Similar to kafka's `segment.ms` config, generally its value should be less 
smaller than logTtl.



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