From 2e43cd9d62530a32ab661ec1a219f3043eac63c8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 1 Dec 2021 10:56:21 +0200 Subject: [PATCH] lib/storage: do not take into account -storage.minFreeDiskSpaceBytes during background merges --- lib/storage/partition.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/storage/partition.go b/lib/storage/partition.go index 22c4b0702b..dbe5920e11 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -978,10 +978,9 @@ func SetFinalMergeDelay(delay time.Duration) { func getMaxOutBytes(path string, workersCount int) uint64 { n := fs.MustGetFreeSpace(path) - if n < freeDiskSpaceLimitBytes { - return 0 - } - n -= freeDiskSpaceLimitBytes + // Do not substract freeDiskSpaceLimitBytes from n before calculating the maxOutBytes, + // since this will result in sub-optimal merges - e.g. many small parts will be left unmerged. + // Divide free space by the max number concurrent merges. maxOutBytes := n / uint64(workersCount) if maxOutBytes > maxBigPartSize {