incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1241619 - in /incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/tabletserver: Tablet.java TabletServer.java
Date Tue, 07 Feb 2012 20:54:35 GMT
Author: kturner
Date: Tue Feb  7 20:54:35 2012
New Revision: 1241619

URL: http://svn.apache.org/viewvc?rev=1241619&view=rev
Log:
ACCUMULO-366 made compact operations on deleted tablets safe

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=1241619&r1=1241618&r2=1241619&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
Tue Feb  7 20:54:35 2012
@@ -124,6 +124,8 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.KeeperException.NoNodeException;
 
 import cloudtrace.instrument.Span;
 import cloudtrace.instrument.Trace;
@@ -2276,6 +2278,7 @@ public class Tablet {
       if (updateMetadata) {
         synchronized (this) {
           updatingFlushID = false;
+          this.notifyAll();
         }
       }
     }
@@ -2283,8 +2286,19 @@ public class Tablet {
   }
   
   boolean initiateMinorCompaction() {
+    if (isClosed()) {
+      // don't bother trying to get flush id if closed... could be closed after this check
but that is ok... just trying to cut down on uneeded log messages....
+      return false;
+    }
+
     // get the flush id before the new memmap is made available for write
-    long flushId = getFlushID();
+    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;
+    }
     return initiateMinorCompaction(flushId);
   }
   
@@ -2340,23 +2354,39 @@ public class Tablet {
     return true;
   }
   
-  long getFlushID() {
+  long getFlushID() throws NoNodeException {
     try {
       String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + extent.getTableId()
           + Constants.ZTABLE_FLUSH_ID;
       return Long.parseLong(new String(ZooReaderWriter.getRetryingInstance().getData(zTablePath,
null)));
-    } catch (Exception e) {
+    } catch (InterruptedException e) {
       throw new RuntimeException(e);
+    } catch (NumberFormatException nfe) {
+      throw new RuntimeException(nfe);
+    } catch (KeeperException ke) {
+      if (ke instanceof NoNodeException) {
+        throw (NoNodeException) ke;
+      } else {
+        throw new RuntimeException(ke);
+      }
     }
   }
   
-  long getCompactionID() {
+  long getCompactionID() throws NoNodeException {
     try {
       String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + extent.getTableId()
           + Constants.ZTABLE_COMPACT_ID;
       return Long.parseLong(new String(ZooReaderWriter.getRetryingInstance().getData(zTablePath,
null)));
-    } catch (Exception e) {
+    } catch (InterruptedException e) {
       throw new RuntimeException(e);
+    } catch (NumberFormatException nfe) {
+      throw new RuntimeException(nfe);
+    } catch (KeeperException ke) {
+      if (ke instanceof NoNodeException) {
+        throw (NoNodeException) ke;
+      } else {
+        throw new RuntimeException(ke);
+      }
     }
   }
   
@@ -2559,13 +2589,25 @@ public class Tablet {
         }
       }
       
+      while (updatingFlushID) {
+        try {
+          this.wait(50);
+        } catch (InterruptedException e) {
+          log.error(e.toString());
+        }
+      }
+
       if (!saveState || tabletMemory.getMemTable().getNumEntries() == 0) {
         return;
       }
       
       tabletMemory.waitForMinC();
       
-      mct = prepareForMinC(getFlushID());
+      try {
+        mct = prepareForMinC(getFlushID());
+      } catch (NoNodeException e) {
+        throw new RuntimeException(e);
+      }
       
       if (queueMinC) {
         tabletResources.executeMinorCompaction(mct);
@@ -2614,7 +2656,11 @@ public class Tablet {
     tabletMemory.waitForMinC();
     
     if (saveState && tabletMemory.getMemTable().getNumEntries() > 0) {
-      prepareForMinC(getFlushID()).run();
+      try {
+        prepareForMinC(getFlushID()).run();
+      } catch (NoNodeException e) {
+        throw new RuntimeException(e);
+      }
     }
     
     if (saveState) {
@@ -3105,7 +3151,11 @@ public class Tablet {
       Long compactionId = null;
       if (!propogateDeletes) {
         // compacting everything, so update the compaction id in !METADATA
-        compactionId = getCompactionID();
+        try {
+          compactionId = getCompactionID();
+        } catch (NoNodeException e) {
+          throw new RuntimeException(e);
+        }
       }
       
       // need to handle case where only one file is being major compacted

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=1241619&r1=1241618&r2=1241619&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
Tue Feb  7 20:54:35 2012
@@ -194,6 +194,7 @@ import org.apache.thrift.TProcessor;
 import org.apache.thrift.TServiceClient;
 import org.apache.thrift.server.TServer;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.KeeperException.NoNodeException;
 
 import cloudtrace.instrument.Span;
 import cloudtrace.instrument.Trace;
@@ -1887,7 +1888,13 @@ public class TabletServer extends Abstra
         if (flushID == null) {
           // read the flush id once from zookeeper instead of reading
           // it for each tablet
-          flushID = tablet.getFlushID();
+          try {
+            flushID = tablet.getFlushID();
+          } catch (NoNodeException e) {
+            // table was probably deleted
+            log.info("Asked to flush table that has no flush id " + ke + " " + e.getMessage());
+            return;
+          }
         }
         tablet.flush(flushID);
       }
@@ -1904,7 +1911,11 @@ public class TabletServer extends Abstra
       Tablet tablet = onlineTablets.get(new KeyExtent(textent));
       if (tablet != null) {
         log.info("Flushing " + tablet.getExtent());
-        tablet.flush(tablet.getFlushID());
+        try {
+          tablet.flush(tablet.getFlushID());
+        } catch (NoNodeException nne) {
+          log.info("Asked to flush tablet that has no flush id " + new KeyExtent(textent)
+ " " + nne.getMessage());
+        }
       }
     }
     
@@ -1999,7 +2010,12 @@ public class TabletServer extends Abstra
         // all for the same table id, so only need to read
         // compaction id once
         if (compactionId == null)
-          compactionId = tablet.getCompactionID();
+          try {
+            compactionId = tablet.getCompactionID();
+          } catch (NoNodeException e) {
+            log.info("Asked to compact table with no compaction id " + ke + " " + e.getMessage());
+            return;
+          }
         tablet.compactAll(compactionId);
       }
       



Mime
View raw message