Browse Source

avoid unexpected compact size (#5272)

https://github.com/seaweedfs/seaweedfs/issues/5215
pull/5335/head
Konstantin Lebedev 10 months ago
committed by GitHub
parent
commit
7187346cc1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      weed/storage/volume_vacuum.go

20
weed/storage/volume_vacuum.go

@ -423,7 +423,10 @@ func (v *Volume) copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, da
if dstDatBackend, err = backend.CreateVolumeFile(dstDatName, preallocate, 0); err != nil {
return err
}
defer dstDatBackend.Close()
defer func() {
dstDatBackend.Sync()
dstDatBackend.Close()
}()
oldNm := needle_map.NewMemDb()
defer oldNm.Close()
@ -484,7 +487,20 @@ func (v *Volume) copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, da
if err != nil {
return err
}
dstDatSize, _, err := dstDatBackend.GetStat()
if err != nil {
return err
}
if v.nm.ContentSize() > v.nm.DeletedSize() {
expectedContentSize := v.nm.ContentSize() - v.nm.DeletedSize()
if expectedContentSize > uint64(dstDatSize) {
return fmt.Errorf("volume %s unexpected new data size: %d does not match size of content minus deleted: %d",
v.Id.String(), dstDatSize, expectedContentSize)
}
} else {
glog.Warningf("volume %s content size: %d less deleted size: %d, new size: %d",
v.Id.String(), v.nm.ContentSize(), v.nm.DeletedSize(), dstDatSize)
}
err = newNm.SaveToIdx(datIdxName)
if err != nil {
return err

Loading…
Cancel
Save