aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-10-26 11:53:18 -0700
committerchrislu <chris.lu@gmail.com>2025-10-26 11:53:18 -0700
commited3788eb80a8f1cde9fb090b478fcd36e289216d (patch)
tree8d24e209000f9ed80176d83b9af92153d38e8d9e
parente3d0f9e4ce5dc7d7fe17cb0719f344b137987d45 (diff)
downloadseaweedfs-ed3788eb80a8f1cde9fb090b478fcd36e289216d.tar.xz
seaweedfs-ed3788eb80a8f1cde9fb090b478fcd36e289216d.zip
check ec shard sizes
-rw-r--r--weed/storage/disk_location_ec.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go
index bb71236c6..5bedd3c8f 100644
--- a/weed/storage/disk_location_ec.go
+++ b/weed/storage/disk_location_ec.go
@@ -316,17 +316,10 @@ func (l *DiskLocation) validateEcVolume(collection string, vid needle.VolumeId)
datFileName := baseFileName + ".dat"
datExists := util.FileExists(datFileName)
- // If .dat is gone, it's a distributed EC volume - any shard count is fine
- // Short-circuit to avoid unnecessary stat calls
- if !datExists {
- glog.V(1).Infof("EC volume %d: distributed EC (.dat removed)", vid)
- return true
- }
-
- // .dat file exists, so we need to validate shard count and size for local EC
shardCount := 0
var expectedShardSize int64 = -1
+ // Count shards and validate they all have the same size (required for Reed-Solomon EC)
for i := 0; i < erasure_coding.TotalShardsCount; i++ {
shardFileName := baseFileName + erasure_coding.ToExt(i)
if fi, err := os.Stat(shardFileName); err == nil {
@@ -347,6 +340,12 @@ func (l *DiskLocation) validateEcVolume(collection string, vid needle.VolumeId)
}
}
+ // If .dat file is gone, this is a distributed EC volume - any shard count is valid
+ if !datExists {
+ glog.V(1).Infof("EC volume %d: distributed EC (.dat removed) with %d shards", vid, shardCount)
+ return true
+ }
+
// If .dat file exists, we need at least DataShardsCount shards locally
// Otherwise it's an incomplete EC encoding that should be cleaned up
if shardCount < erasure_coding.DataShardsCount {