some changes to prepare fix after failed reads

This commit is contained in:
Chris Lu 2020-10-08 18:33:06 -07:00
parent 78859e35fc
commit bd8b9b0c2e
3 changed files with 8 additions and 3 deletions

View file

@ -93,6 +93,10 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
} else if hasEcVolume { } else if hasEcVolume {
count, err = vs.store.ReadEcShardNeedle(volumeId, n) count, err = vs.store.ReadEcShardNeedle(volumeId, n)
} }
if err != nil && err != storage.ErrorDeleted && r.FormValue("type") != "replicate" && hasVolume {
glog.V(4).Infoln("read needle: %v", err)
// start to fix it from other replicas, if not deleted and hasVolume and is not a replicated 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(3).Infof("read %s isNormalVolume %v error: %v", r.URL.Path, hasVolume, err) glog.V(3).Infof("read %s isNormalVolume %v error: %v", r.URL.Path, hasVolume, err)

View file

@ -128,7 +128,7 @@ func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, e
return 0, fmt.Errorf("locate in local ec volume: %v", err) return 0, fmt.Errorf("locate in local ec volume: %v", err)
} }
if size.IsDeleted() { if size.IsDeleted() {
return 0, fmt.Errorf("entry %s is deleted", n.Id) return 0, ErrorDeleted
} }
glog.V(3).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToAcutalOffset(), size, intervals) glog.V(3).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToAcutalOffset(), size, intervals)
@ -141,7 +141,7 @@ func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, e
return 0, fmt.Errorf("ReadEcShardIntervals: %v", err) return 0, fmt.Errorf("ReadEcShardIntervals: %v", err)
} }
if isDeleted { if isDeleted {
return 0, fmt.Errorf("ec entry %s is deleted", n.Id) return 0, ErrorDeleted
} }
err = n.ReadBytes(bytes, offset.ToAcutalOffset(), size, localEcVolume.Version) err = n.ReadBytes(bytes, offset.ToAcutalOffset(), size, localEcVolume.Version)

View file

@ -16,6 +16,7 @@ import (
) )
var ErrorNotFound = errors.New("not found") var ErrorNotFound = errors.New("not found")
var ErrorDeleted = errors.New("already deleted")
// isFileUnchanged checks whether this needle to write is same as last one. // isFileUnchanged checks whether this needle to write is same as last one.
// It requires serialized access in the same volume. // It requires serialized access in the same volume.
@ -266,7 +267,7 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro
glog.V(3).Infof("reading deleted %s", n.String()) glog.V(3).Infof("reading deleted %s", n.String())
readSize = -readSize readSize = -readSize
} else { } else {
return -1, errors.New("already deleted") return -1, ErrorDeleted
} }
} }
if readSize == 0 { if readSize == 0 {