1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-02 16:50:25 +02:00
This commit is contained in:
chrislu 2022-02-07 11:38:01 -08:00
commit b1cff07ab0
2 changed files with 12 additions and 0 deletions

View file

@ -26,6 +26,9 @@ func (s *Store) CompactVolume(vid needle.VolumeId, preallocate int64, compaction
return fmt.Errorf("volume id %d is not found during compact", vid)
}
func (s *Store) CommitCompactVolume(vid needle.VolumeId) (bool, error) {
if s.isStopping {
return false, fmt.Errorf("volume id %d skips compact because volume is stopping", vid)
}
if v := s.findVolume(vid); v != nil {
return v.IsReadOnly(), v.CommitCompact()
}

View file

@ -289,6 +289,9 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
return fmt.Errorf("ReadNeedleBlob %s key %d offset %d size %d failed: %v", oldDatFile.Name(), key, increIdxEntry.offset.ToActualOffset(), increIdxEntry.size, err)
}
dstDatBackend.Write(needleBytes)
if err := dstDatBackend.Sync(); err != nil {
return fmt.Errorf("cannot sync needle %s: %v", dstDatBackend.File.Name(), err)
}
util.Uint32toBytes(idxEntryBytes[8:12], uint32(offset/NeedlePaddingSize))
} else { //deleted needle
//fakeDelNeedle 's default Data field is nil
@ -308,6 +311,12 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
newIdxFileName, err)
}
_, err = idx.Write(idxEntryBytes)
if err != nil {
return fmt.Errorf("cannot write indexfile %s: %v", newIdxFileName, err)
}
if err := idx.Sync(); err != nil {
return fmt.Errorf("cannot sync indexfile %s: %v", newIdxFileName, err)
}
}
return nil