mirror of
https://github.com/octoleo/restic.git
synced 2024-11-11 07:41:03 +00:00
cache: ignore ErrNotExist during cleanup of old files
Two restic processes running concurrently can try to remove the same files from the cache. This could cause one process to fail with an error if the other one has already remove a file that the current process also tries to delete.
This commit is contained in:
parent
6091029fd6
commit
0747cf5319
8
changelog/unreleased/issue-4760
Normal file
8
changelog/unreleased/issue-4760
Normal file
@ -0,0 +1,8 @@
|
||||
Bugfix: Fix possible error on concurrent cache cleanup
|
||||
|
||||
If multiple restic processes concurrently cleaned up no longer existing files
|
||||
from the cache, this could cause some of the processes to fail with an `no such
|
||||
file or directory` error. This has been fixed.
|
||||
|
||||
https://github.com/restic/restic/issues/4760
|
||||
https://github.com/restic/restic/pull/4761
|
3
internal/cache/file.go
vendored
3
internal/cache/file.go
vendored
@ -165,7 +165,8 @@ func (c *Cache) Clear(t restic.FileType, valid restic.IDSet) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = fs.Remove(c.filename(backend.Handle{Type: t, Name: id.String()})); err != nil {
|
||||
// ignore ErrNotExist to gracefully handle multiple processes running Clear() concurrently
|
||||
if err = fs.Remove(c.filename(backend.Handle{Type: t, Name: id.String()})); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user