Copilot commented on code in PR #3623:
URL: https://github.com/apache/fluss/pull/3623#discussion_r3575789242


##########
fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java:
##########
@@ -556,10 +594,12 @@ public void updateRemoteLogSize(long remoteLogSize) {
     public void updateRemoteLogEndOffset(long remoteLogEndOffset) {
         if (remoteLogEndOffset > this.remoteLogEndOffset) {
             this.remoteLogEndOffset = remoteLogEndOffset;
-
-            // try to delete these segments already exist in remote storage.
-            deleteSegmentsAlreadyExistsInRemote();
         }
+
+        // Try to delete segments that have already existed in remote storage 
on every retention
+        // pass. A remote TTL cleanup may leave the manifest end offset 
unchanged or decrease it,
+        // but locally retained inactive segments may have expired in the 
meantime.
+        deleteSegmentsAlreadyExistsInRemote();
     }

Review Comment:
   `updateRemoteLogEndOffset()` triggers local deletion via 
`deleteSegmentsAlreadyExistsInRemote()`, but that cleanup is ultimately gated 
by the LogTablet field `remoteLogEndOffset` (which is only ever increased and 
starts at -1). If all remote segments expire and `RemoteLogTablet` resets its 
end offset back to -1, a restarted replica may keep `remoteLogEndOffset == -1` 
(see `RemoteLogManager.registerReplica()` which only calls 
`updateRemoteLogEndOffset()` when the optional end offset is present). In that 
case, TTL-based cleanup for tier-protected inactive local segments may never 
run for an idle table, leaving expired segments on disk indefinitely.



##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/source/FlinkTableSourceBatchITCase.java:
##########
@@ -75,15 +75,15 @@ void before() {
         tEnv.executeSql("use catalog " + CATALOG_NAME);
 
         
tEnv.getConfig().set(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM,
 4);
-        // create database
-        tEnv.executeSql("create database " + DEFAULT_DB);
-        tEnv.useDatabase(DEFAULT_DB);
+        databaseName = "defaultdb_" + RandomUtils.nextInt();
+        tEnv.executeSql("create database " + databaseName);
+        tEnv.useDatabase(databaseName);
     }
 
     @AfterEach
     void after() {
         tEnv.useDatabase(BUILTIN_DATABASE);
-        tEnv.executeSql(String.format("drop database %s cascade", DEFAULT_DB));
+        tEnv.executeSql(String.format("drop database %s cascade", 
databaseName));
     }

Review Comment:
   `after()` assumes both `tEnv` and `databaseName` are always initialized by 
`before()`. If `before()` fails early (e.g., catalog creation fails), `after()` 
can throw NPE and mask the original failure, and it will also attempt to drop a 
possibly-uncreated database. Guarding the cleanup makes test failures easier to 
diagnose.



##########
fluss-server/src/test/java/org/apache/fluss/server/log/remote/TieredLocalSegmentTtlTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.fluss.server.log.remote;
+
+import org.apache.fluss.config.ConfigOptions;
+import org.apache.fluss.metadata.TableBucket;
+import org.apache.fluss.server.log.LogTablet;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.time.Duration;
+import java.util.Collections;
+
+import static org.apache.fluss.record.TestData.DATA1_SCHEMA;
+import static org.apache.fluss.record.TestData.DATA1_TABLE_ID;
+import static org.apache.fluss.record.TestData.DATA1_TABLE_PATH;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests TTL-based cleanup of inactive local segments retained by tiered 
storage. */
+final class TieredLocalSegmentTtlTest extends RemoteLogTestBase {
+

Review Comment:
   The test class name uses mixed-case acronym `Ttl`, while existing remote-log 
tests use `TTL` (e.g., `RemoteLogTTLTest`). Renaming to 
`TieredLocalSegmentTTLTest` would better match the established naming 
convention for acronyms in this module.



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