Author: jbellis
Date: Thu Feb 24 15:14:19 2011
New Revision: 1074185

URL: http://svn.apache.org/viewvc?rev=1074185&view=rev
Log:
improve detection and cleanup ofpartially-written sstables
patch by jbellis; reviewed by gdusbabek for CASSANDRA-2206

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1074185&r1=1074184&r2=1074185&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Thu Feb 24 15:14:19 2011
@@ -27,6 +27,8 @@
  * fat clients were writing local data (CASSANDRA-2223)
  * turn off string interning in json2sstable (CASSANDRA-2189)
  * set DEFAULT_MEMTABLE_LIFETIME_IN_MINS to 24h
+ * improve detection and cleanup of partially-written sstables 
+   (CASSANDRA-2206)
 
 
 0.7.2

Modified: 
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1074185&r1=1074184&r2=1074185&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
 (original)
+++ 
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
 Thu Feb 24 15:14:19 2011
@@ -22,9 +22,12 @@ package org.apache.cassandra.io.sstable;
 import java.io.*;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import com.google.common.collect.Sets;
+
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -204,8 +207,10 @@ public class SSTableWriter extends SSTab
         Descriptor newdesc = tmpdesc.asTemporary(false);
         try
         {
-            for (Component component : components)
+            // do -Data last because -Data present should mean the sstable was 
completely renamed before crash
+            for (Component component : Sets.difference(components, 
Collections.singleton(Component.DATA)))
                 FBUtilities.renameWithConfirm(tmpdesc.filenameFor(component), 
newdesc.filenameFor(component));
+            FBUtilities.renameWithConfirm(tmpdesc.filenameFor(Component.DATA), 
newdesc.filenameFor(Component.DATA));
         }
         catch (IOException e)
         {


Reply via email to