mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix ec related bugs
This commit is contained in:
parent
450f4733ce
commit
d344e0a035
|
@ -76,7 +76,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||||
}
|
}
|
||||||
glog.V(4).Infoln("read bytes", count, "error", err)
|
glog.V(4).Infoln("read bytes", count, "error", err)
|
||||||
if err != nil || count < 0 {
|
if err != nil || count < 0 {
|
||||||
glog.V(0).Infof("read %s error: %v", r.URL.Path, err)
|
glog.V(0).Infof("read %s isNormalVolume %v error: %v", r.URL.Path, hasVolume, err)
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,7 @@ func doDeduplicateEcShards(ctx context.Context, commandEnv *CommandEnv, collecti
|
||||||
if err := sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, ecNode.info.Id, duplicatedShardIds); err != nil {
|
if err := sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, ecNode.info.Id, duplicatedShardIds); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
deleteEcVolumeShards(ecNode, vid, duplicatedShardIds)
|
||||||
ecNode.freeEcSlot++
|
ecNode.freeEcSlot++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,3 +274,27 @@ func findEcVolumeShards(ecNode *EcNode, vid needle.VolumeId) erasure_coding.Shar
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addEcVolumeShards(ecNode *EcNode, vid needle.VolumeId, shardIds []uint32){
|
||||||
|
|
||||||
|
for _, shardInfo := range ecNode.info.EcShardInfos {
|
||||||
|
if needle.VolumeId(shardInfo.Id) == vid {
|
||||||
|
for _, shardId := range shardIds{
|
||||||
|
shardInfo.EcIndexBits = uint32(erasure_coding.ShardBits(shardInfo.EcIndexBits).AddShardId(erasure_coding.ShardId(shardId)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteEcVolumeShards(ecNode *EcNode, vid needle.VolumeId, shardIds []uint32){
|
||||||
|
|
||||||
|
for _, shardInfo := range ecNode.info.EcShardInfos {
|
||||||
|
if needle.VolumeId(shardInfo.Id) == vid {
|
||||||
|
for _, shardId := range shardIds{
|
||||||
|
shardInfo.EcIndexBits = uint32(erasure_coding.ShardBits(shardInfo.EcIndexBits).RemoveShardId(erasure_coding.ShardId(shardId)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -35,7 +35,14 @@ func moveMountedShardToEcNode(ctx context.Context, commandEnv *CommandEnv, exist
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask source node to delete the shard, and maybe the ecx file
|
// ask source node to delete the shard, and maybe the ecx file
|
||||||
return sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, existingLocation.info.Id, copiedShardIds)
|
err = sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, existingLocation.info.Id, copiedShardIds)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteEcVolumeShards(existingLocation, vid, copiedShardIds)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,8 @@ func rebuildOneEcVolume(ctx context.Context, commandEnv *CommandEnv, rebuilder *
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addEcVolumeShards(rebuilder, volumeId, generatedShardIds)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,8 @@ func (l *DiskLocation) Close() {
|
||||||
l.Unlock()
|
l.Unlock()
|
||||||
|
|
||||||
l.ecVolumesLock.Lock()
|
l.ecVolumesLock.Lock()
|
||||||
for _, shards := range l.ecVolumes {
|
for _, ecVolume := range l.ecVolumes {
|
||||||
shards.Close()
|
ecVolume.Close()
|
||||||
}
|
}
|
||||||
l.ecVolumesLock.Unlock()
|
l.ecVolumesLock.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ func (l *DiskLocation) UnloadEcShard(vid needle.VolumeId, shardId erasure_coding
|
||||||
if _, deleted := ecVolume.DeleteEcVolumeShard(shardId); deleted {
|
if _, deleted := ecVolume.DeleteEcVolumeShard(shardId); deleted {
|
||||||
if len(ecVolume.Shards) == 0 {
|
if len(ecVolume.Shards) == 0 {
|
||||||
delete(l.ecVolumes, vid)
|
delete(l.ecVolumes, vid)
|
||||||
}
|
|
||||||
ecVolume.Close()
|
ecVolume.Close()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ func (ev *EcVolume) LocateEcShardNeedle(n *needle.Needle, version needle.Version
|
||||||
// find the needle from ecx file
|
// find the needle from ecx file
|
||||||
offset, size, err = ev.findNeedleFromEcx(n.Id)
|
offset, size, err = ev.findNeedleFromEcx(n.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.Offset{}, 0, nil, err
|
return types.Offset{}, 0, nil, fmt.Errorf("findNeedleFromEcx: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
shard := ev.Shards[0]
|
shard := ev.Shards[0]
|
||||||
|
@ -173,7 +173,7 @@ func (ev *EcVolume) findNeedleFromEcx(needleId types.NeedleId) (offset types.Off
|
||||||
for l < h {
|
for l < h {
|
||||||
m := (l + h) / 2
|
m := (l + h) / 2
|
||||||
if _, err := ev.ecxFile.ReadAt(buf, m*types.NeedleMapEntrySize); err != nil {
|
if _, err := ev.ecxFile.ReadAt(buf, m*types.NeedleMapEntrySize); err != nil {
|
||||||
return types.Offset{}, 0, err
|
return types.Offset{}, 0, fmt.Errorf("ecx file %d read at %d: %v", ev.ecxFileSize, m*types.NeedleMapEntrySize, err)
|
||||||
}
|
}
|
||||||
key, offset, size = idx.IdxFileEntry(buf)
|
key, offset, size = idx.IdxFileEntry(buf)
|
||||||
if key == needleId {
|
if key == needleId {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (s *Store) ReadEcShardNeedle(ctx context.Context, vid needle.VolumeId, n *n
|
||||||
|
|
||||||
offset, size, intervals, err := localEcVolume.LocateEcShardNeedle(n, version)
|
offset, size, intervals, err := localEcVolume.LocateEcShardNeedle(n, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, fmt.Errorf("locate in local ec volume: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(4).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToAcutalOffset(), size, intervals)
|
glog.V(4).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToAcutalOffset(), size, intervals)
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (t *Topology) Leader() (string, error) {
|
||||||
return l, nil
|
return l, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Topology) Lookup(collection string, vid needle.VolumeId) []*DataNode {
|
func (t *Topology) Lookup(collection string, vid needle.VolumeId) (dataNodes []*DataNode) {
|
||||||
//maybe an issue if lots of collections?
|
//maybe an issue if lots of collections?
|
||||||
if collection == "" {
|
if collection == "" {
|
||||||
for _, c := range t.collectionMap.Items() {
|
for _, c := range t.collectionMap.Items() {
|
||||||
|
@ -91,6 +91,14 @@ func (t *Topology) Lookup(collection string, vid needle.VolumeId) []*DataNode {
|
||||||
return c.(*Collection).Lookup(vid)
|
return c.(*Collection).Lookup(vid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if locations, found := t.LookupEcShards(vid); found {
|
||||||
|
for _, loc := range locations.Locations {
|
||||||
|
dataNodes = append(dataNodes, loc...)
|
||||||
|
}
|
||||||
|
return dataNodes
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue