incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1303841 - in /incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver: Tablet.java TabletServer.java
Date Thu, 22 Mar 2012 15:37:19 GMT
Author: ecn
Date: Thu Mar 22 15:37:19 2012
New Revision: 1303841

URL: http://svn.apache.org/viewvc?rev=1303841&view=rev
Log:
ACCUMULO-484 use the tablet load thread to perform the minor compaction after recovery

Modified:
    incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
    incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java

Modified: incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java?rev=1303841&r1=1303840&r2=1303841&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
(original)
+++ incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
Thu Mar 22 15:37:19 2012
@@ -2302,8 +2302,30 @@ public class Tablet {
     return initiateMinorCompaction(flushId);
   }
   
+  boolean minorCompactNow() {
+    long flushId;
+    try {
+      flushId = getFlushID();
+    } catch (NoNodeException e) {
+      log.info("Asked to initiate MinC when there was no flush id " + getExtent() + " " +
e.getMessage());
+      return false;
+    }
+    MinorCompactionTask mct = createMinorCompactionTask(flushId);
+    if (mct == null)
+      return false;
+    mct.run();
+    return true;
+  }
+
   boolean initiateMinorCompaction(long flushId) {
-    
+    MinorCompactionTask mct = createMinorCompactionTask(flushId);
+    if (mct == null)
+      return false;
+    tabletResources.executeMinorCompaction(mct);
+    return true;
+  }
+  
+  private MinorCompactionTask createMinorCompactionTask(long flushId) {
     MinorCompactionTask mct;
     long t1, t2;
     
@@ -2328,14 +2350,14 @@ public class Tablet {
             logMessage.append(" tabletMemory.getMemTable().getNumEntries() " + tabletMemory.getMemTable().getNumEntries());
           logMessage.append(" updatingFlushID " + updatingFlushID);
           
-          return false;
+          return null;
         }
         // We're still recovering log entries
         if (datafileManager == null) {
           logMessage = new StringBuilder();
           logMessage.append(extent.toString());
           logMessage.append(" datafileManager " + datafileManager);
-          return false;
+          return null;
         }
         
         mct = prepareForMinC(flushId);
@@ -2347,11 +2369,8 @@ public class Tablet {
         log.debug(logMessage);
     }
     
-    tabletResources.executeMinorCompaction(mct);
-    
     log.debug(String.format("MinC initiate lock %.2f secs", (t2 - t1) / 1000.0));
-    
-    return true;
+    return mct;
   }
   
   long getFlushID() throws NoNodeException {

Modified: incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java?rev=1303841&r1=1303840&r2=1303841&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
(original)
+++ incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
Thu Mar 22 15:37:19 2012
@@ -2409,21 +2409,18 @@ public class TabletServer extends Abstra
           // this opens the tablet file and fills in the endKey in the
           // extent
           tablet = new Tablet(TabletServer.this, locationToOpen, extentToOpen, trm, tabletsKeyValues);
-          if (tablet.initiateMinorCompaction()) {
-            /*
-             * If a minor compaction starts after a tablet opens, this indicates a log recovery
occurred. This recovered data must be minor compacted.
-             * 
-             * There are three reasons to wait for this minor compaction to finish before
placing the tablet in online tablets.
-             * 
-             * 1) The log recovery code does not handle data written to the tablet on multiple
tablet servers. 2) The log recovery code does not block if memory
-             * is full. Therefore recovering lots of tablets that use a lot of memory could
run out of memory. 3) The minor compaction finish event did not make
-             * it to the logs (the file will be in !METADATA, preventing replay of compacted
data)... but do not want a majc to wipe the file out from !METADATA
-             * and then have another process failure... this could cause duplicate data to
replay
-             */
-
-            tablet.waitForMinC();
-          } else if (tablet.getNumEntriesInMemory() > 0) {
-            log.warn("Minor compaction after recovery fails for " + extentToOpen);
+          /*
+           * If a minor compaction starts after a tablet opens, this indicates a log recovery
occurred. This recovered data must be minor compacted.
+           * 
+           * There are three reasons to wait for this minor compaction to finish before placing
the tablet in online tablets.
+           * 
+           * 1) The log recovery code does not handle data written to the tablet on multiple
tablet servers. 2) The log recovery code does not block if memory
+           * is full. Therefore recovering lots of tablets that use a lot of memory could
run out of memory. 3) The minor compaction finish event did not make
+           * it to the logs (the file will be in !METADATA, preventing replay of compacted
data)... but do not want a majc to wipe the file out from !METADATA
+           * and then have another process failure... this could cause duplicate data to
replay
+           */
+          if (tablet.getNumEntriesInMemory() > 0 && !tablet.minorCompactNow())
{
+            throw new RuntimeException("Minor compaction after recovery fails for " + extentToOpen);
           }
           
           Assignment assignment = new Assignment(extentToOpen, getTabletSession());



Mime
View raw message