From ed3788eb80a8f1cde9fb090b478fcd36e289216d Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 26 Oct 2025 11:53:18 -0700 Subject: [PATCH] check ec shard sizes --- weed/storage/disk_location_ec.go | 15 +++++++-------- 1 file 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 {