forked from TrueCloudLab/rclone
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
f6970c65dd
commit
43ad7b10a2
2 changed files with 7 additions and 1 deletions
|
@ -609,7 +609,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…
Add table
Reference in a new issue