From 4001ca36b8671a92e655b975cc864ac1ca64042c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 30 Mar 2024 01:39:27 +0200 Subject: [PATCH] lib/storage/partition.go: reduce code difference a bit with enterprise branch --- lib/storage/partition.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/storage/partition.go b/lib/storage/partition.go index 598042f3f..5ab20be64 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -1331,28 +1331,23 @@ func (pt *partition) releasePartsToMerge(pws []*partWrapper) { } func (pt *partition) runFinalDedup() error { - requiredDedupInterval, actualDedupInterval := pt.getRequiredDedupInterval() t := time.Now() - logger.Infof("starting final dedup for partition %s using requiredDedupInterval=%d ms, since the partition has smaller actualDedupInterval=%d ms", - pt.bigPartsPath, requiredDedupInterval, actualDedupInterval) + logger.Infof("start removing duplicate samples from partition (%s, %s)", pt.bigPartsPath, pt.smallPartsPath) if err := pt.ForceMergeAllParts(pt.stopCh); err != nil { - return fmt.Errorf("cannot perform final dedup for partition %s: %w", pt.bigPartsPath, err) + return fmt.Errorf("cannot remove duplicate samples from partition (%s, %s): %w", pt.bigPartsPath, pt.smallPartsPath, err) } - logger.Infof("final dedup for partition %s has been finished in %.3f seconds", pt.bigPartsPath, time.Since(t).Seconds()) + logger.Infof("duplicate samples have been removed from partition (%s, %s) in %.3f seconds", pt.bigPartsPath, pt.smallPartsPath, time.Since(t).Seconds()) return nil } func (pt *partition) isFinalDedupNeeded() bool { - requiredDedupInterval, actualDedupInterval := pt.getRequiredDedupInterval() - return requiredDedupInterval > actualDedupInterval -} - -func (pt *partition) getRequiredDedupInterval() (int64, int64) { - pws := pt.GetParts(nil, false) - defer pt.PutParts(pws) dedupInterval := GetDedupInterval() + + pws := pt.GetParts(nil, false) minDedupInterval := getMinDedupInterval(pws) - return dedupInterval, minDedupInterval + pt.PutParts(pws) + + return dedupInterval > minDedupInterval } func getMinDedupInterval(pws []*partWrapper) int64 {