mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-18 04:37:52 +08:00
fix write volume over size MaxPossibleVolumeSize (#5190)
Co-authored-by: Yang Wang <yangwang@weride.ai>
This commit is contained in:
parent
b0ac3ebd6c
commit
0e8a54f6f6
@ -127,7 +127,7 @@ func (n *Needle) Append(w backend.BackendStorageFile, version Version) (offset u
|
||||
err = fmt.Errorf("Cannot Read Current Volume Position: %v", e)
|
||||
return
|
||||
}
|
||||
if offset >= MaxPossibleVolumeSize && n.Size.IsValid() {
|
||||
if offset >= MaxPossibleVolumeSize && len(n.Data) != 0 {
|
||||
err = fmt.Errorf("Volume Size %d Exceeded %d", offset, MaxPossibleVolumeSize)
|
||||
return
|
||||
}
|
||||
|
@ -107,16 +107,9 @@ func (v *Volume) asyncRequestAppend(request *needle.AsyncRequest) {
|
||||
|
||||
func (v *Volume) syncWrite(n *needle.Needle, checkCookie bool) (offset uint64, size Size, isUnchanged bool, err error) {
|
||||
// glog.V(4).Infof("writing needle %s", needle.NewFileIdFromNeedle(v.Id, n).String())
|
||||
actualSize := needle.GetActualSize(Size(len(n.Data)), v.Version())
|
||||
|
||||
v.dataFileAccessLock.Lock()
|
||||
defer v.dataFileAccessLock.Unlock()
|
||||
|
||||
if MaxPossibleVolumeSize < v.nm.ContentSize()+uint64(actualSize) {
|
||||
err = fmt.Errorf("volume size limit %d exceeded! current size is %d", MaxPossibleVolumeSize, v.nm.ContentSize())
|
||||
return
|
||||
}
|
||||
|
||||
return v.doWriteRequest(n, checkCookie)
|
||||
}
|
||||
|
||||
@ -193,7 +186,6 @@ func (v *Volume) doWriteRequest(n *needle.Needle, checkCookie bool) (offset uint
|
||||
|
||||
func (v *Volume) syncDelete(n *needle.Needle) (Size, error) {
|
||||
// glog.V(4).Infof("delete needle %s", needle.NewFileIdFromNeedle(v.Id, n).String())
|
||||
actualSize := needle.GetActualSize(0, v.Version())
|
||||
v.dataFileAccessLock.Lock()
|
||||
defer v.dataFileAccessLock.Unlock()
|
||||
|
||||
@ -201,11 +193,6 @@ func (v *Volume) syncDelete(n *needle.Needle) (Size, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
if MaxPossibleVolumeSize < v.nm.ContentSize()+uint64(actualSize) {
|
||||
err := fmt.Errorf("volume size limit %d exceeded! current size is %d", MaxPossibleVolumeSize, v.nm.ContentSize())
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return v.doDeleteRequest(n)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user