mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
EC: with multiple volume locations, the ec rebuilding may fail
This commit is contained in:
parent
5790d01c6f
commit
fb5808e0c3
|
@ -90,6 +90,15 @@ func (vs *VolumeServer) VolumeEcShardsRebuild(ctx context.Context, req *volume_s
|
||||||
var rebuiltShardIds []uint32
|
var rebuiltShardIds []uint32
|
||||||
|
|
||||||
for _, location := range vs.store.Locations {
|
for _, location := range vs.store.Locations {
|
||||||
|
_, _, existingShardCount, err := checkEcVolumeStatus(bName, location)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if existingShardCount == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if util.FileExists(path.Join(location.IdxDirectory, baseFileName+".ecx")) {
|
if util.FileExists(path.Join(location.IdxDirectory, baseFileName+".ecx")) {
|
||||||
// write .ec00 ~ .ec13 files
|
// write .ec00 ~ .ec13 files
|
||||||
dataBaseFileName := path.Join(location.Directory, baseFileName)
|
dataBaseFileName := path.Join(location.Directory, baseFileName)
|
||||||
|
@ -206,19 +215,36 @@ func deleteEcShardIdsForEachLocation(bName string, location *storage.DiskLocatio
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// check whether to delete the .ecx and .ecj file also
|
hasEcxFile, hasIdxFile, existingShardCount, err := checkEcVolumeStatus(bName, location)
|
||||||
hasEcxFile := false
|
|
||||||
hasIdxFile := false
|
|
||||||
existingShardCount := 0
|
|
||||||
|
|
||||||
fileInfos, err := os.ReadDir(location.Directory)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hasEcxFile && existingShardCount == 0 {
|
||||||
|
if err := os.Remove(indexBaseFilename + ".ecx"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
os.Remove(indexBaseFilename + ".ecj")
|
||||||
|
|
||||||
|
if !hasIdxFile {
|
||||||
|
// .vif is used for ec volumes and normal volumes
|
||||||
|
os.Remove(dataBaseFilename + ".vif")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkEcVolumeStatus(bName string, location *storage.DiskLocation) (hasEcxFile bool, hasIdxFile bool, existingShardCount int, err error) {
|
||||||
|
// check whether to delete the .ecx and .ecj file also
|
||||||
|
fileInfos, err := os.ReadDir(location.Directory)
|
||||||
|
if err != nil {
|
||||||
|
return false, false, 0, err
|
||||||
|
}
|
||||||
if location.IdxDirectory != location.Directory {
|
if location.IdxDirectory != location.Directory {
|
||||||
idxFileInfos, err := os.ReadDir(location.IdxDirectory)
|
idxFileInfos, err := os.ReadDir(location.IdxDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, false, 0, err
|
||||||
}
|
}
|
||||||
fileInfos = append(fileInfos, idxFileInfos...)
|
fileInfos = append(fileInfos, idxFileInfos...)
|
||||||
}
|
}
|
||||||
|
@ -235,20 +261,7 @@ func deleteEcShardIdsForEachLocation(bName string, location *storage.DiskLocatio
|
||||||
existingShardCount++
|
existingShardCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return hasEcxFile, hasIdxFile, existingShardCount, nil
|
||||||
if hasEcxFile && existingShardCount == 0 {
|
|
||||||
if err := os.Remove(indexBaseFilename + ".ecx"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
os.Remove(indexBaseFilename + ".ecj")
|
|
||||||
|
|
||||||
if !hasIdxFile {
|
|
||||||
// .vif is used for ec volumes and normal volumes
|
|
||||||
os.Remove(dataBaseFilename + ".vif")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vs *VolumeServer) VolumeEcShardsMount(ctx context.Context, req *volume_server_pb.VolumeEcShardsMountRequest) (*volume_server_pb.VolumeEcShardsMountResponse, error) {
|
func (vs *VolumeServer) VolumeEcShardsMount(ctx context.Context, req *volume_server_pb.VolumeEcShardsMountRequest) (*volume_server_pb.VolumeEcShardsMountResponse, error) {
|
||||||
|
|
Loading…
Reference in a new issue