Skip to content

Commit

Permalink
[BugFix] update storage_cache_ttl default 30 days (StarRocks#13228)
Browse files Browse the repository at this point in the history
  • Loading branch information
abc982627271 authored Nov 15, 2022
1 parent 73d0575 commit e8af424
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ public void analyze(int partColNum, Map<String, String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down

0 comments on commit e8af424

Please sign in to comment.