diff --git a/fe/fe-core/src/main/java/com/starrocks/common/Config.java b/fe/fe-core/src/main/java/com/starrocks/common/Config.java index 6ec10d56e1ab8..6944311b5591a 100644 --- a/fe/fe-core/src/main/java/com/starrocks/common/Config.java +++ b/fe/fe-core/src/main/java/com/starrocks/common/Config.java @@ -1073,6 +1073,7 @@ public class Config extends ConfigBase { @ConfField(mutable = true, aliases = {"storage_cooldown_second"}) public static long tablet_sched_storage_cooldown_second = -1L; // won't cool down by default + /** * FOR BeLoadBalancer: * the threshold of cluster balance score, if a backend's load score is 10% lower than average score, @@ -1687,6 +1688,12 @@ public class Config extends ConfigBase { @ConfField public static String starmgr_s3_sk = ""; + /** + * default storage cache ttl of lake table + */ + @ConfField(mutable = true) + public static long lake_default_storage_cache_ttl_seconds = 2592000L; + /** * default bucket number when create OLAP table without buckets info */ diff --git a/fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java b/fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java index 7fcb364b39f69..fa71d95d2cc21 100644 --- a/fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java +++ b/fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java @@ -2038,18 +2038,19 @@ private void createOlapOrLakeTable(Database db, CreateTableStmt stmt) throws Ddl long storageCacheTtlS = 0; try { storageCacheTtlS = PropertyAnalyzer.analyzeLongProp(properties, - PropertyAnalyzer.PROPERTIES_STORAGE_CACHE_TTL, 0); + PropertyAnalyzer.PROPERTIES_STORAGE_CACHE_TTL, Config.lake_default_storage_cache_ttl_seconds); } catch (AnalysisException e) { throw new DdlException(e.getMessage()); } if (storageCacheTtlS < -1) { throw new DdlException("Storage cache ttl should not be less than -1"); } - if (!enableStorageCache && storageCacheTtlS != 0) { + if (!enableStorageCache && storageCacheTtlS != 0 && + storageCacheTtlS != Config.lake_default_storage_cache_ttl_seconds) { throw new DdlException("Storage cache ttl should be 0 when cache is disabled"); } if (enableStorageCache && storageCacheTtlS == 0) { - storageCacheTtlS = Config.tablet_sched_storage_cooldown_second; + throw new DdlException("Storage cache ttl should not be 0 when cache is enabled"); } // set to false if absent diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/ast/SingleRangePartitionDesc.java b/fe/fe-core/src/main/java/com/starrocks/sql/ast/SingleRangePartitionDesc.java index c1a62fa1678af..5009d4d72b097 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/ast/SingleRangePartitionDesc.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/ast/SingleRangePartitionDesc.java @@ -137,18 +137,18 @@ public void analyze(int partColNum, Map otherProperties) throws boolean enableStorageCache = PropertyAnalyzer.analyzeBooleanProp( properties, PropertyAnalyzer.PROPERTIES_ENABLE_STORAGE_CACHE, false); long storageCacheTtlS = PropertyAnalyzer.analyzeLongProp( - properties, PropertyAnalyzer.PROPERTIES_STORAGE_CACHE_TTL, 0); + properties, PropertyAnalyzer.PROPERTIES_STORAGE_CACHE_TTL, Config.lake_default_storage_cache_ttl_seconds); boolean allowAsyncWriteBack = PropertyAnalyzer.analyzeBooleanProp( properties, PropertyAnalyzer.PROPERTIES_ALLOW_ASYNC_WRITE_BACK, false); if (storageCacheTtlS < -1) { throw new AnalysisException("Storage cache ttl should not be less than -1"); } - if (!enableStorageCache && storageCacheTtlS != 0) { + if (!enableStorageCache && storageCacheTtlS != 0 && storageCacheTtlS != Config.lake_default_storage_cache_ttl_seconds) { throw new AnalysisException("Storage cache ttl should be 0 when cache is disabled"); } if (enableStorageCache && storageCacheTtlS == 0) { - storageCacheTtlS = Config.tablet_sched_storage_cooldown_second; + throw new AnalysisException("Storage cache ttl should not be 0 when cache is enabled"); } if (!enableStorageCache && allowAsyncWriteBack) { throw new AnalysisException("storage allow_async_write_back can't be enabled when cache is disabled"); diff --git a/fe/fe-core/src/test/java/com/starrocks/lake/CreateLakeTableTest.java b/fe/fe-core/src/test/java/com/starrocks/lake/CreateLakeTableTest.java index cc545bfb4d067..812ad39bdccc9 100644 --- a/fe/fe-core/src/test/java/com/starrocks/lake/CreateLakeTableTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/lake/CreateLakeTableTest.java @@ -194,16 +194,16 @@ public void testCreateLakeTableWithStorageCache(@Mocked StarOSAgent agent) throw // check table property StorageInfo storageInfo = lakeTable.getTableProperty().getStorageInfo(); Assert.assertFalse(storageInfo.isEnableStorageCache()); - Assert.assertEquals(0, storageInfo.getStorageCacheTtlS()); + Assert.assertEquals(Config.lake_default_storage_cache_ttl_seconds, storageInfo.getStorageCacheTtlS()); // check partition property long partition1Id = lakeTable.getPartition("p1").getId(); StorageCacheInfo partition1StorageCacheInfo = lakeTable.getPartitionInfo().getStorageCacheInfo(partition1Id); Assert.assertFalse(partition1StorageCacheInfo.isEnableStorageCache()); - Assert.assertEquals(0, partition1StorageCacheInfo.getStorageCacheTtlS()); + Assert.assertEquals(Config.lake_default_storage_cache_ttl_seconds, partition1StorageCacheInfo.getStorageCacheTtlS()); long partition2Id = lakeTable.getPartition("p2").getId(); StorageCacheInfo partition2StorageCacheInfo = lakeTable.getPartitionInfo().getStorageCacheInfo(partition2Id); Assert.assertTrue(partition2StorageCacheInfo.isEnableStorageCache()); - Assert.assertEquals(Config.tablet_sched_storage_cooldown_second, + Assert.assertEquals(Config.lake_default_storage_cache_ttl_seconds, partition2StorageCacheInfo.getStorageCacheTtlS()); } }