Skip to content

Commit

Permalink
Reduce scan interval in cleanupDeletedFiles (#5343)
Browse files Browse the repository at this point in the history
Signed-off-by: Changxin Miao <[email protected]>
  • Loading branch information
polyrabbit authored Dec 6, 2024
1 parent ad85c0f commit fc3a8b6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,18 +611,22 @@ func (m *baseMeta) Init(format *Format, force bool) error {

func (m *baseMeta) cleanupDeletedFiles() {
for {
utils.SleepWithJitter(time.Minute)
if ok, err := m.en.setIfSmall("lastCleanupFiles", time.Now().Unix(), int64(time.Minute.Seconds())*9/10); err != nil {
utils.SleepWithJitter(time.Hour)
if ok, err := m.en.setIfSmall("lastCleanupFiles", time.Now().Unix(), int64(time.Hour.Seconds())*9/10); err != nil {
logger.Warnf("checking counter lastCleanupFiles: %s", err)
} else if ok {
files, err := m.en.doFindDeletedFiles(time.Now().Add(-time.Hour).Unix(), 10000)
files, err := m.en.doFindDeletedFiles(time.Now().Add(-time.Hour).Unix(), 6e5)
if err != nil {
logger.Warnf("scan deleted files: %s", err)
continue
}
start := time.Now()
for inode, length := range files {
logger.Debugf("cleanup chunks of inode %d with %d bytes", inode, length)
m.en.doDeleteFileData(inode, length)
if time.Since(start) > 50*time.Minute { // Yield my time slice to avoid conflicts with other clients
break
}
}
}
}
Expand Down

0 comments on commit fc3a8b6

Please sign in to comment.