cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r1021467 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/db/CompactionManager.java src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
Date Mon, 11 Oct 2010 19:10:32 GMT
Author: gdusbabek
Date: Mon Oct 11 19:10:31 2010
New Revision: 1021467

URL: http://svn.apache.org/viewvc?rev=1021467&view=rev
Log:
abandon temp sstables on compaction error. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1596

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1021467&r1=1021466&r2=1021467&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Mon Oct 11 19:10:31 2010
@@ -26,6 +26,7 @@ dev
  * reduce index sample time by 75% (CASSANDRA-1572)
  * add cli support for column metadata (CASSANDRA-1578)
  * add cli support for schema modification (CASSANDRA-1584)
+ * delete temp files on failed compactions (CASSANDRA-1596)
 
 
 0.7-beta2

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=1021467&r1=1021466&r2=1021467&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Mon Oct 11 19:10:31
2010
@@ -283,9 +283,16 @@ public class CompactionManager implement
             while (nni.hasNext())
             {
                 AbstractCompactedRow row = nni.next();
-                long prevpos = writer.getFilePointer();
-
-                writer.append(row);
+                try
+                {
+                    writer.append(row);
+                }
+                catch (IOException ex)
+                {
+                    writer.abort();
+                    // rethrow the exception so that caller knows compaction failed.
+                    throw ex;
+                }
                 totalkeysWritten++;
             }
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1021467&r1=1021466&r2=1021467&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Mon Oct 11
19:10:31 2010
@@ -22,6 +22,7 @@ package org.apache.cassandra.io.sstable;
 import java.io.*;
 import java.util.Set;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,6 +66,30 @@ public class SSTableWriter extends SSTab
         components.add(Component.PRIMARY_INDEX);
         components.add(Component.STATS);
     }
+    
+    /** something bad happened and the files associated with this writer need to be deleted.
*/
+    public void abort()
+    {
+        try
+        {
+            dataFile.close();
+            FileUtils.deleteWithConfirm(dataFile.getPath());
+        }
+        catch (IOException ex) 
+        {
+            logger.error(String.format("Caught exception while deleting aborted sstable (%s).
%s", dataFile.getPath(), ex.getMessage()));
+        }
+        
+        try
+        {
+            iwriter.close();
+            FileUtils.deleteWithConfirm(descriptor.filenameFor(SSTable.COMPONENT_INDEX));
+        }
+        catch (IOException ex)
+        {
+            logger.error(String.format("Caught exception while deleting aborted sstable (%s).
%s", descriptor.filenameFor(SSTable.COMPONENT_INDEX), ex.getMessage()));
+        }
+    }
 
     private long beforeAppend(DecoratedKey decoratedKey) throws IOException
     {



Mime
View raw message