aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-10-26 01:28:18 -0700
committerchrislu <chris.lu@gmail.com>2025-10-26 01:28:18 -0700
commit51edda33561265e232b1686dfd913f0eb1f923be (patch)
treeaf484ddc9e49cf9f0ab5e36d39e333114b9addfa
parent6f7ceb63eb9364252fd84d5f1bede866bc0750b2 (diff)
downloadseaweedfs-51edda33561265e232b1686dfd913f0eb1f923be.tar.xz
seaweedfs-51edda33561265e232b1686dfd913f0eb1f923be.zip
simplify, and better logs
-rw-r--r--weed/storage/disk_location_ec.go40
1 files changed, 25 insertions, 15 deletions
diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go
index e710c87d4..5286ad84f 100644
--- a/weed/storage/disk_location_ec.go
+++ b/weed/storage/disk_location_ec.go
@@ -233,18 +233,16 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
if len(sameVolumeShards) > 0 && prevVolumeId != 0 {
// We have collected EC shards but never found .ecx file
// 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]))]
- collection, volumeId, err := parseCollectionVolumeId(baseName)
- if err == nil && volumeId == prevVolumeId {
- baseFileName := erasure_coding.EcShardFileName(collection, l.Directory, int(volumeId))
- datFileName := baseFileName + ".dat"
- // Only clean up if .dat file exists (incomplete encoding, not distributed EC)
- if util.FileExists(datFileName) {
- glog.Warningf("Found %d EC shards without .ecx file for volume %d (incomplete encoding interrupted before .ecx creation), cleaning up...",
- len(sameVolumeShards), volumeId)
- l.removeEcVolumeFiles(collection, volumeId)
- }
+ baseName := sameVolumeShards[0][:len(sameVolumeShards[0])-len(path.Ext(sameVolumeShards[0]))]
+ collection, volumeId, err := parseCollectionVolumeId(baseName)
+ if err == nil && volumeId == prevVolumeId {
+ baseFileName := erasure_coding.EcShardFileName(collection, l.Directory, int(volumeId))
+ datFileName := baseFileName + ".dat"
+ // Only clean up if .dat file exists (incomplete encoding, not distributed EC)
+ if util.FileExists(datFileName) {
+ glog.Warningf("Found %d EC shards without .ecx file for volume %d (incomplete encoding interrupted before .ecx creation), cleaning up...",
+ len(sameVolumeShards), volumeId)
+ l.removeEcVolumeFiles(collection, volumeId)
}
}
}
@@ -336,16 +334,28 @@ func (l *DiskLocation) removeEcVolumeFiles(collection string, vid needle.VolumeI
// Remove all EC shard files (.ec00 ~ .ec13)
for i := 0; i < erasure_coding.TotalShardsCount; 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)
}
}
// 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)
}
- 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)
}
}