lib/storage: remove ForceMergeAllParts internal loop (#4999)

Signed-off-by: faceair <git@faceair.me>
This commit is contained in:
faceair 2023-09-16 01:04:54 +08:00 committed by Aliaksandr Valialkin
parent 77756c7acc
commit 3045ba01f5
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -936,7 +936,7 @@ func (pt *partition) ForceMergeAllParts() error {
// Nothing to merge. // Nothing to merge.
return nil return nil
} }
for {
// Check whether there is enough disk space for merging pws. // Check whether there is enough disk space for merging pws.
newPartSize := getPartsSize(pws) newPartSize := getPartsSize(pws)
maxOutBytes := fs.MustGetFreeSpace(pt.bigPartsPath) maxOutBytes := fs.MustGetFreeSpace(pt.bigPartsPath)
@ -953,12 +953,8 @@ func (pt *partition) ForceMergeAllParts() error {
if err := pt.mergePartsOptimal(pws, pt.stopCh); err != nil { if err := pt.mergePartsOptimal(pws, pt.stopCh); err != nil {
return fmt.Errorf("cannot force merge %d parts from partition %q: %w", len(pws), pt.name, err) return fmt.Errorf("cannot force merge %d parts from partition %q: %w", len(pws), pt.name, err)
} }
pws = pt.getAllPartsForMerge()
if len(pws) <= 1 {
pt.releasePartsToMerge(pws)
return nil return nil
}
}
} }
var forceMergeLogger = logger.WithThrottler("forceMerge", time.Minute) var forceMergeLogger = logger.WithThrottler("forceMerge", time.Minute)