mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
vfs: Add exponential backoff during ENOSPC retries
Add an exponentially increasing delay during retries up ENOSPC error to avoid exhausting the 10 retries too soon when the cache space recovery from item resets is not available from the file system yet or consumed by other large cache writes.
This commit is contained in:
parent
ff0280c0cb
commit
2295123cad
|
@ -610,7 +610,6 @@ func (c *Cache) clean(removeCleanFiles bool) {
|
|||
if os.IsNotExist(err) {
|
||||
return
|
||||
}
|
||||
|
||||
c.mu.Lock()
|
||||
oldItems, oldUsed := len(c.item), fs.SizeSuffix(c.used)
|
||||
c.mu.Unlock()
|
||||
|
|
|
@ -1182,6 +1182,7 @@ func (item *Item) setModTime(modTime time.Time) {
|
|||
// ReadAt bytes from the file at off
|
||||
func (item *Item) ReadAt(b []byte, off int64) (n int, err error) {
|
||||
n = 0
|
||||
var expBackOff int
|
||||
for retries := 0; retries < fs.Config.LowLevelRetries; retries++ {
|
||||
item.preAccess()
|
||||
n, err = item.readAt(b, off)
|
||||
|
@ -1195,6 +1196,12 @@ func (item *Item) ReadAt(b []byte, off int64) (n int, err error) {
|
|||
break
|
||||
}
|
||||
item.c.KickCleaner()
|
||||
expBackOff = 2 << uint(retries)
|
||||
time.Sleep(time.Duration(expBackOff) * time.Millisecond) // Exponential back-off the retries
|
||||
}
|
||||
|
||||
if fserrors.IsErrNoSpace(err) {
|
||||
fs.Errorf(item.name, "vfs cache: failed to _ensure cache after retries %v", err)
|
||||
}
|
||||
|
||||
return n, err
|
||||
|
|
Loading…
Reference in New Issue
Block a user