You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2010/04/17 21:50:37 UTC

svn commit: r935240 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/Store.java

Author: stack
Date: Sat Apr 17 19:50:36 2010
New Revision: 935240

URL: http://svn.apache.org/viewvc?rev=935240&view=rev
Log:
HBASE-2457 RS gets stuck compacting region ad infinitum

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/Store.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=935240&r1=935239&r2=935240&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Sat Apr 17 19:50:36 2010
@@ -84,6 +84,7 @@ Release 0.20.4 - Unreleased
                (Kannan Muthukkaruppan via Stack)
    HBASE-2451   .META. by-passes cache; BLOCKCACHE=>'false'
    HBASE-2456   deleteChangedReaderObserver spitting warnings after HBASE-2248
+   HBASE-2457  RS gets stuck compacting region ad infinitum
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=935240&r1=935239&r2=935240&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/Store.java Sat Apr 17 19:50:36 2010
@@ -726,7 +726,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;
@@ -738,9 +738,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];