Browse Source

fix Inconsistent error handling: should continue to next location.

pull/7465/head
chrislu 4 weeks ago
parent
commit
3b35508720
  1. 32
      weed/command/backup.go

32
weed/command/backup.go

@ -141,23 +141,31 @@ func runBackup(cmd *Command, args []string) bool {
v, err := storage.NewVolume(util.ResolvePath(*s.dir), util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, ver, 0, 0) v, err := storage.NewVolume(util.ResolvePath(*s.dir), util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, ver, 0, 0)
if err != nil { if err != nil {
fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)
return true
fmt.Printf("Error creating or reading from volume %d from %s: %v\n", vid, volumeServer, err)
lastErr = err
continue
} }
if v.SuperBlock.CompactionRevision < uint16(stats.CompactRevision) { if v.SuperBlock.CompactionRevision < uint16(stats.CompactRevision) {
if err = v.Compact2(0, 0, nil); err != nil { if err = v.Compact2(0, 0, nil); err != nil {
fmt.Printf("Compact Volume before synchronizing %v\n", err)
fmt.Printf("Compact Volume before synchronizing from %s: %v\n", volumeServer, err)
v.Close() v.Close()
return true
lastErr = err
continue
} }
if err = v.CommitCompact(); err != nil { if err = v.CommitCompact(); err != nil {
fmt.Printf("Commit Compact before synchronizing %v\n", err)
fmt.Printf("Commit Compact before synchronizing from %s: %v\n", volumeServer, err)
v.Close() v.Close()
return true
lastErr = err
continue
} }
v.SuperBlock.CompactionRevision = uint16(stats.CompactRevision) v.SuperBlock.CompactionRevision = uint16(stats.CompactRevision)
v.DataBackend.WriteAt(v.SuperBlock.Bytes(), 0)
if _, err = v.DataBackend.WriteAt(v.SuperBlock.Bytes(), 0); err != nil {
fmt.Printf("Error writing superblock from %s: %v\n", volumeServer, err)
v.Close()
lastErr = err
continue
}
} }
datSize, _, _ := v.FileStat() datSize, _, _ := v.FileStat()
@ -165,13 +173,17 @@ func runBackup(cmd *Command, args []string) bool {
if datSize > stats.TailOffset { if datSize > stats.TailOffset {
// remove the old data // remove the old data
if err := v.Destroy(false); err != nil { if err := v.Destroy(false); err != nil {
fmt.Printf("Error destroying volume: %v\n", err)
fmt.Printf("Error destroying volume from %s: %v\n", volumeServer, err)
v.Close()
lastErr = err
continue
} }
// recreate an empty volume // recreate an empty volume
v, err = storage.NewVolume(util.ResolvePath(*s.dir), util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, ver, 0, 0) v, err = storage.NewVolume(util.ResolvePath(*s.dir), util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, ver, 0, 0)
if err != nil { if err != nil {
fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)
return true
fmt.Printf("Error recreating volume %d from %s: %v\n", vid, volumeServer, err)
lastErr = err
continue
} }
} }

Loading…
Cancel
Save