Browse Source
can vacuum volume when size mismatch (#5200)
Co-authored-by: Yang Wang <yangwang@weride.ai>
pull/5207/head
skycope
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
14 additions and
4 deletions
-
weed/storage/needle/needle_read.go
-
weed/storage/volume_checking.go
-
weed/storage/volume_read.go
|
|
@ -93,7 +93,17 @@ func (n *Needle) ReadData(r backend.BackendStorageFile, offset int64, size Size, |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return n.ReadBytes(bytes, offset, size, version) |
|
|
|
|
|
|
|
err = n.ReadBytes(bytes, offset, size, version) |
|
|
|
if err == ErrorSizeMismatch && OffsetSize == 4 { |
|
|
|
offset = offset + int64(MaxPossibleVolumeSize) |
|
|
|
bytes, err = ReadNeedleBlob(r, offset, size, version) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
err = n.ReadBytes(bytes, offset, size, version) |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
func (n *Needle) ParseNeedleHeader(bytes []byte) { |
|
|
|
|
|
@ -60,6 +60,9 @@ func doCheckAndFixVolumeData(v *Volume, indexFile *os.File, indexOffset int64) ( |
|
|
|
} |
|
|
|
} else { |
|
|
|
if lastAppendAtNs, err = verifyNeedleIntegrity(v.DataBackend, v.Version(), offset.ToActualOffset(), key, size); err != nil { |
|
|
|
if err == ErrorSizeMismatch { |
|
|
|
return verifyNeedleIntegrity(v.DataBackend, v.Version(), offset.ToActualOffset()+int64(MaxPossibleVolumeSize), key, size) |
|
|
|
} |
|
|
|
return lastAppendAtNs, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -55,9 +55,6 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption, onReadSize |
|
|
|
} |
|
|
|
if readOption == nil || !readOption.IsMetaOnly { |
|
|
|
err = n.ReadData(v.DataBackend, nv.Offset.ToActualOffset(), readSize, v.Version()) |
|
|
|
if err == needle.ErrorSizeMismatch && OffsetSize == 4 { |
|
|
|
err = n.ReadData(v.DataBackend, nv.Offset.ToActualOffset()+int64(MaxPossibleVolumeSize), readSize, v.Version()) |
|
|
|
} |
|
|
|
v.checkReadWriteError(err) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|