From 0de2a9322e24f9028a4e45b2a0fdbf82bf341fb8 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Thu, 16 Jan 2025 18:26:12 +0000 Subject: [PATCH] Fixed DefaultCompactionPlanner.findFilesToCompactWithLowerRatio logic Fixed logic to break out of loop when a set of files is found that meets the criteria. Loop was continuing and ended up using the lowest possible ratio above 1.1. --- .../spi/compaction/DefaultCompactionPlanner.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/spi/compaction/DefaultCompactionPlanner.java b/core/src/main/java/org/apache/accumulo/core/spi/compaction/DefaultCompactionPlanner.java index 6c60d5095cf..e1e829e4fe7 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/compaction/DefaultCompactionPlanner.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/compaction/DefaultCompactionPlanner.java @@ -382,8 +382,13 @@ private Collection findFilesToCompactWithLowerRatio(PlanningPar goalCompactionSize = 0; } + // If the highRatio is 1.1 or less, then we will never get + // into the loop below. + boolean checkPerformed = false; + // Do a binary search of the compaction ratios. while (highRatio - lowRatio > .1) { + checkPerformed = true; double ratioToCheck = (highRatio - lowRatio) / 2 + lowRatio; // This is continually resorting the list of files in the following call, could optimize this @@ -399,12 +404,17 @@ private Collection findFilesToCompactWithLowerRatio(PlanningPar lowRatio = ratioToCheck; found = filesToCompact; } + + if (!found.isEmpty()) { + break; + } + } - if (found.isEmpty() && lowRatio == 1.0) { + if (checkPerformed && found.isEmpty() && lowRatio == 1.0) { // in this case the data must be really skewed, operator intervention may be needed. log.warn( - "Attempted to lower compaction ration from {} to {} for {} because there are {} files " + "Attempted to lower compaction ratio from {} to {} for {} because there are {} files " + "and the max tablet files is {}, however no set of files to compact were found.", params.getRatio(), highRatio, params.getTableId(), params.getCandidates().size(), maxTabletFiles);