Author: stack Date: Mon May 17 22:23:32 2010 New Revision: 945410 URL: http://svn.apache.org/viewvc?rev=945410&view=rev Log: HBASE-2457 RS gets stuck compacting region ad infinitum
Modified: hadoop/hbase/trunk/CHANGES.txt hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Modified: hadoop/hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=945410&r1=945409&r2=945410&view=diff ============================================================================== --- hadoop/hbase/trunk/CHANGES.txt (original) +++ hadoop/hbase/trunk/CHANGES.txt Mon May 17 22:23:32 2010 @@ -326,6 +326,9 @@ Release 0.21.0 - Unreleased (Nicolas Spiegelberg via Stack) HBASE-2415 Disable META splitting in 0.20 (Todd Lipcon via Stack) HBASE-2421 Put hangs for 10 retries on failed region servers + HBASE-2442 Log lease recovery catches IOException too widely + (Todd Lipcon via Stack) + HBASE-2457 RS gets stuck compacting region ad infinitum IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable Modified: hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=945410&r1=945409&r2=945410&view=diff ============================================================================== --- hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original) +++ hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Mon May 17 22:23:32 2010 @@ -722,7 +722,7 @@ public class Store implements HConstants Reader r = file.getReader(); if (r == null) { LOG.warn("StoreFile " + file + " has a null Reader"); - continue; + return null; } long len = file.getReader().length(); fileSizes[i] = len; @@ -734,9 +734,16 @@ public class Store implements HConstants // The rule is: if the largest(oldest) one is more than twice the // size of the second, skip the largest, and continue to next..., // until we meet the compactionThreshold limit. - for (point = 0; point < countOfFiles - 1; point++) { - if ((fileSizes[point] < fileSizes[point + 1] * 2) && - (countOfFiles - point) <= maxFilesToCompact) { + + // A problem with the above heuristic is that we could go through all of + // filesToCompact and the above condition could hold for all files and + // we'd end up with nothing to compact. To protect against this, we'll + // compact the tail -- up to the last 4 files -- of filesToCompact + // regardless. + int tail = Math.min(countOfFiles, 4); + for (point = 0; point < (countOfFiles - tail); point++) { + if (((fileSizes[point] < fileSizes[point + 1] * 2) && + (countOfFiles - point) <= maxFilesToCompact)) { break; } skipped += fileSizes[point];