Browse Source

simplify, and better logs

pull/7384/head
chrislu 1 month ago
parent
commit
51edda3356
  1. 20
      weed/storage/disk_location_ec.go

20
weed/storage/disk_location_ec.go

@ -233,7 +233,6 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
if len(sameVolumeShards) > 0 && prevVolumeId != 0 { if len(sameVolumeShards) > 0 && prevVolumeId != 0 {
// We have collected EC shards but never found .ecx file // We have collected EC shards but never found .ecx file
// Need to determine the collection name from the shard filenames // Need to determine the collection name from the shard filenames
if len(sameVolumeShards) > 0 {
baseName := sameVolumeShards[0][:len(sameVolumeShards[0])-len(path.Ext(sameVolumeShards[0]))] baseName := sameVolumeShards[0][:len(sameVolumeShards[0])-len(path.Ext(sameVolumeShards[0]))]
collection, volumeId, err := parseCollectionVolumeId(baseName) collection, volumeId, err := parseCollectionVolumeId(baseName)
if err == nil && volumeId == prevVolumeId { if err == nil && volumeId == prevVolumeId {
@ -247,7 +246,6 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
} }
} }
} }
}
return nil return nil
} }
@ -336,16 +334,28 @@ func (l *DiskLocation) removeEcVolumeFiles(collection string, vid needle.VolumeI
// Remove all EC shard files (.ec00 ~ .ec13) // Remove all EC shard files (.ec00 ~ .ec13)
for i := 0; i < erasure_coding.TotalShardsCount; i++ { for i := 0; i < erasure_coding.TotalShardsCount; i++ {
shardFileName := baseFileName + erasure_coding.ToExt(i) shardFileName := baseFileName + erasure_coding.ToExt(i)
if err := os.Remove(shardFileName); err == nil {
if err := os.Remove(shardFileName); err != nil {
if !os.IsNotExist(err) {
glog.Warningf("Failed to remove incomplete EC shard file %s: %v", shardFileName, err)
}
} else {
glog.V(0).Infof("Removed incomplete EC shard file: %s", shardFileName) glog.V(0).Infof("Removed incomplete EC shard file: %s", shardFileName)
} }
} }
// Remove index files // Remove index files
if err := os.Remove(indexBaseFileName + ".ecx"); err == nil {
if err := os.Remove(indexBaseFileName + ".ecx"); err != nil {
if !os.IsNotExist(err) {
glog.Warningf("Failed to remove incomplete EC index file %s.ecx: %v", indexBaseFileName, err)
}
} else {
glog.V(0).Infof("Removed incomplete EC index file: %s.ecx", indexBaseFileName) glog.V(0).Infof("Removed incomplete EC index file: %s.ecx", indexBaseFileName)
} }
if err := os.Remove(indexBaseFileName + ".ecj"); err == nil {
if err := os.Remove(indexBaseFileName + ".ecj"); err != nil {
if !os.IsNotExist(err) {
glog.Warningf("Failed to remove incomplete EC journal file %s.ecj: %v", indexBaseFileName, err)
}
} else {
glog.V(0).Infof("Removed incomplete EC journal file: %s.ecj", indexBaseFileName) glog.V(0).Infof("Removed incomplete EC journal file: %s.ecj", indexBaseFileName)
} }
} }
Loading…
Cancel
Save