diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-08-26 09:16:58 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-08-26 09:16:58 -0700 |
| commit | ab759f0ec2185a256b9164e72132790b7bc7696b (patch) | |
| tree | 6193f96cbd034aa3c68e980305296c396d3133f3 | |
| parent | d1cf39f1800f56df86bda90de0331175896a8998 (diff) | |
| download | seaweedfs-ab759f0ec2185a256b9164e72132790b7bc7696b.tar.xz seaweedfs-ab759f0ec2185a256b9164e72132790b7bc7696b.zip | |
erasure coding: fix EC error if multiple disks are configured in one volume server
| -rw-r--r-- | weed/storage/disk_location_ec.go | 4 | ||||
| -rw-r--r-- | weed/storage/erasure_coding/ec_shard.go | 4 | ||||
| -rw-r--r-- | weed/storage/store_ec.go | 3 |
3 files changed, 11 insertions, 0 deletions
diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go index 72d3e2b3e..07fab96d9 100644 --- a/weed/storage/disk_location_ec.go +++ b/weed/storage/disk_location_ec.go @@ -3,6 +3,7 @@ package storage import ( "fmt" "io/ioutil" + "os" "path" "regexp" "sort" @@ -58,6 +59,9 @@ func (l *DiskLocation) LoadEcShard(collection string, vid needle.VolumeId, shard ecVolumeShard, err := erasure_coding.NewEcVolumeShard(l.Directory, collection, vid, shardId) if err != nil { + if err == os.ErrNotExist { + return os.ErrNotExist + } return fmt.Errorf("failed to create ec shard %d.%d: %v", vid, shardId, err) } l.ecVolumesLock.Lock() diff --git a/weed/storage/erasure_coding/ec_shard.go b/weed/storage/erasure_coding/ec_shard.go index 0c1746f42..74ed99198 100644 --- a/weed/storage/erasure_coding/ec_shard.go +++ b/weed/storage/erasure_coding/ec_shard.go @@ -5,6 +5,7 @@ import ( "os" "path" "strconv" + "strings" "github.com/chrislusf/seaweedfs/weed/stats" "github.com/chrislusf/seaweedfs/weed/storage/needle" @@ -29,6 +30,9 @@ func NewEcVolumeShard(dirname string, collection string, id needle.VolumeId, sha // open ecd file if v.ecdFile, e = os.OpenFile(baseFileName+ToExt(int(shardId)), os.O_RDONLY, 0644); e != nil { + if e == os.ErrNotExist || strings.Contains(e.Error(), "no such file or directory") { + return nil, os.ErrNotExist + } return nil, fmt.Errorf("cannot read ec volume shard %s%s: %v", baseFileName, ToExt(int(shardId)), e) } ecdFi, statErr := v.ecdFile.Stat() diff --git a/weed/storage/store_ec.go b/weed/storage/store_ec.go index 8b4388519..bd7bdacbd 100644 --- a/weed/storage/store_ec.go +++ b/weed/storage/store_ec.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io" + "os" "sort" "sync" "time" @@ -59,6 +60,8 @@ func (s *Store) MountEcShards(collection string, vid needle.VolumeId, shardId er EcIndexBits: uint32(shardBits.AddShardId(shardId)), } return nil + } else if err == os.ErrNotExist { + continue } else { return fmt.Errorf("%s load ec shard %d.%d: %v", location.Directory, vid, shardId, err) } |
