mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #11899 from tedyu/rel-snap-db
etcdserver: continue releasing snap db in case of error
This commit is contained in:
commit
8b50f4e11d
@ -260,7 +260,7 @@ func (s *Snapshotter) cleanupSnapdir(filenames []string) error {
|
||||
if strings.HasPrefix(filename, "db.tmp") {
|
||||
s.lg.Info("found orphaned defragmentation file; deleting", zap.String("path", filename))
|
||||
if rmErr := os.Remove(filepath.Join(s.dir, filename)); rmErr != nil && !os.IsNotExist(rmErr) {
|
||||
return fmt.Errorf("failed to remove orphaned defragmentation file %s: %v", filename, rmErr)
|
||||
return fmt.Errorf("failed to remove orphaned .snap.db file %s: %v", filename, rmErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,12 +282,13 @@ func (s *Snapshotter) ReleaseSnapDBs(snap raftpb.Snapshot) error {
|
||||
hexIndex := strings.TrimSuffix(filepath.Base(filename), ".snap.db")
|
||||
index, err := strconv.ParseUint(hexIndex, 16, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse index from .snap.db filename %q: %v", filename, err)
|
||||
s.lg.Error("failed to parse index from filename", zap.String("path", filename), zap.String("error", err.Error()))
|
||||
continue
|
||||
}
|
||||
if index < snap.Metadata.Index {
|
||||
s.lg.Info("found orphaned .snap.db file; deleting", zap.String("path", filename))
|
||||
if rmErr := os.Remove(filepath.Join(s.dir, filename)); rmErr != nil && !os.IsNotExist(rmErr) {
|
||||
return fmt.Errorf("failed to remove orphaned defragmentation file %s: %v", filename, rmErr)
|
||||
s.lg.Error("failed to remove orphaned .snap.db file", zap.String("path", filename), zap.String("error", rmErr.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user