Skip to content

Commit

Permalink
fix stageBlockBytes calculation method (#3462)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Apr 12, 2023
1 parent f1c475d commit 8bf5c69
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/chunk/disk_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,9 @@ func (cache *cacheStore) remove(key string) {
cache.Unlock()
if path != "" {
_ = os.Remove(path)
stagingPath := cache.stagePath(key)
if fi, err := os.Stat(stagingPath); err == nil {
size := fi.Size()
if err = os.Remove(stagingPath); err == nil {
cache.m.stageBlocks.Sub(1)
cache.m.stageBlockBytes.Sub(float64(size))
}
if err := os.Remove(cache.stagePath(key)); err == nil {
cache.m.stageBlocks.Sub(1)
cache.m.stageBlockBytes.Sub(float64(parseObjOrigSize(key)))
}
}
}
Expand Down Expand Up @@ -543,13 +539,14 @@ func (cache *cacheStore) scanStaging() {
logger.Warnf("Ignore invalid file in staging: %s", path)
return nil
}
if parseObjOrigSize(key) == 0 {
origSize := parseObjOrigSize(key)
if origSize == 0 {
logger.Warnf("Ignore file with zero size: %s", path)
return nil
}
logger.Debugf("Found staging block: %s", path)
cache.m.stageBlocks.Add(1)
cache.m.stageBlockBytes.Add(float64(fi.Size()))
cache.m.stageBlockBytes.Add(float64(origSize))
cache.uploader(key, path, false)
count++
}
Expand Down

0 comments on commit 8bf5c69

Please sign in to comment.