diff --git a/datanode/partition.go b/datanode/partition.go index a68b7aae8..1cdd4f25f 100644 --- a/datanode/partition.go +++ b/datanode/partition.go @@ -1503,7 +1503,7 @@ func (dp *DataPartition) setRestoreReplicaFinish() bool { } func (dp *DataPartition) EvictExtentCache() { - err := dp.extentStore.DoExtentCacheTtl(dp.dataNode.ExtentCacheTtlByHour) + err := dp.extentStore.DoExtentCacheTtl(dp.dataNode.ExtentCacheTtlByMin) if err != nil { log.LogWarnf("[EvictExtentCache] DoExtentCacheTtl err: %s", err.Error()) } diff --git a/datanode/server.go b/datanode/server.go index 551317533..18db70b03 100644 --- a/datanode/server.go +++ b/datanode/server.go @@ -71,7 +71,7 @@ const ( DefaultDiskUnavailableErrorCount = 5 DefaultDiskUnavailablePartitionErrorCount = 3 DefaultGOGCValue = 100 - DefaultExtentCacheTtlByHour = 1 + DefaultExtentCacheTtlByMin = 30 ) const ( @@ -137,7 +137,7 @@ const ( // disk status becomes unavailable if disk error partition count reaches this value ConfigKeyDiskUnavailablePartitionErrorCount = "diskUnavailablePartitionErrorCount" ConfigKeyCacheCap = "cacheCap" - ConfigExtentCacheTtlByHour = "extentCacheTtlByHour" + ConfigExtentCacheTtlByMin = "extentCacheTtlByMin" // storage device media type, for hybrid cloud, in string: SDD or HDD ConfigMediaType = "mediaType" @@ -223,7 +223,7 @@ type DataNode struct { VolsForbidWriteOpOfProtoVer0 map[string]struct{} // whether forbid by volume granularity, DirectReadVols map[string]struct{} IgnoreTinyRecoverVols map[string]struct{} - ExtentCacheTtlByHour int + ExtentCacheTtlByMin int } type verOp2Phase struct { @@ -478,7 +478,7 @@ func (s *DataNode) parseConfig(cfg *config.Config) (err error) { } s.mediaType = mediaType - s.ExtentCacheTtlByHour = cfg.GetIntWithDefault(ConfigExtentCacheTtlByHour, DefaultExtentCacheTtlByHour) + s.ExtentCacheTtlByMin = cfg.GetIntWithDefault(ConfigExtentCacheTtlByMin, DefaultExtentCacheTtlByMin) log.LogDebugf("action[parseConfig] load masterAddrs(%v).", MasterClient.Nodes()) log.LogDebugf("action[parseConfig] load port(%v).", s.port) diff --git a/datanode/space_manager.go b/datanode/space_manager.go index 69a19ac4b..5e1b4f03b 100644 --- a/datanode/space_manager.go +++ b/datanode/space_manager.go @@ -969,7 +969,11 @@ func (manager *SpaceManager) getPartitions() []*DataPartition { } func (manager *SpaceManager) StartEvictExtentCache() { - ticker := time.NewTicker(time.Hour) + interval := manager.dataNode.ExtentCacheTtlByMin / 2 + if interval <= 0 { + interval = 1 + } + ticker := time.NewTicker(time.Minute * time.Duration(interval)) defer ticker.Stop() for { diff --git a/datanode/storage/extent_cache.go b/datanode/storage/extent_cache.go index 50ab0dbff..2ffd4d87f 100644 --- a/datanode/storage/extent_cache.go +++ b/datanode/storage/extent_cache.go @@ -224,7 +224,7 @@ func (cache *ExtentCache) Flush() { } func (cache *ExtentCache) EvictTTL(ttl int) error { - cmpTime := timeutil.GetCurrentTimeUnix() - int64(ttl)*int64(time.Hour) + cmpTime := timeutil.GetCurrentTimeUnix() - int64(ttl)*int64(time.Minute) if cache.capacity <= 0 || cmpTime <= 0 { return nil }