Skip to content

Commit

Permalink
Tolerate file deletion race on CurrentShadowWALIndex
Browse files Browse the repository at this point in the history
Commit e0493f9 exposed a race
between CurrentShadowWALIndex and copyToShadowWAL where the temp
file could exist during os.ReadDir but not when actually checking
the file size.

Said race is quite uncommon and should be mostly harmless as the
monitor will retry soon anyway but not having locking around these
operations might cause other undesired effects.

This commit fixes the immediate issue of failing for the wrong
reason.
  • Loading branch information
hifi committed Dec 18, 2023
1 parent 676810c commit bb74f56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func (db *DB) CurrentShadowWALIndex(generation string) (index int, size int64, e
// Find highest wal index.
for _, de := range des {
fi, err := de.Info()
if err != nil {
if os.IsNotExist(err) {
continue // file was deleted after os.ReadDir returned
} else if err != nil {
return 0, 0, err
}

Expand Down

0 comments on commit bb74f56

Please sign in to comment.