You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2016/07/21 14:03:59 UTC

[3/6] cassandra git commit: Faster startup by only scanning each directory for temporary files once

Faster startup by only scanning each directory for temporary files once

patch by Jeff Jirsa; reviewed by Joel Knighton for CASSANDRA-12114


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/864e009b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/864e009b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/864e009b

Branch: refs/heads/trunk
Commit: 864e009b0853741fc33de5ab4e6384cacef48ca8
Parents: 904137c
Author: Jeff Jirsa <je...@crowdstrike.com>
Authored: Tue Jul 5 23:19:12 2016 -0700
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Thu Jul 21 15:01:28 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/864e009b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9acd89e..eb73da2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.9
+ * Faster startup by only scanning each directory for temporary files once (CASSANDRA-12114)
  * Respond with v1/v2 protocol header when responding to driver that attempts
    to connect with too low of a protocol version (CASSANDRA-11464)
  * NullPointerExpception when reading/compacting table (CASSANDRA-11988)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/864e009b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index b95e88d..f34a2d5 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -581,6 +581,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
     public static void scrubDataDirectories(CFMetaData metadata)
     {
         Directories directories = new Directories(metadata, initialDirectories);
+        Set<File> cleanedDirectories = new HashSet<>();
 
          // clear ephemeral snapshots that were not properly cleared last session (CASSANDRA-7357)
         clearEphemeralSnapshots(directories);
@@ -594,10 +595,15 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         for (Map.Entry<Descriptor,Set<Component>> sstableFiles : directories.sstableLister(Directories.OnTxnErr.IGNORE).list().entrySet())
         {
             Descriptor desc = sstableFiles.getKey();
+            File directory = desc.directory;
             Set<Component> components = sstableFiles.getValue();
 
-            for (File tmpFile : desc.getTemporaryFiles())
-                tmpFile.delete();
+            if (!cleanedDirectories.contains(directory))
+            {
+                cleanedDirectories.add(directory);
+                for (File tmpFile : desc.getTemporaryFiles())
+                    tmpFile.delete();
+            }
 
             File dataFile = new File(desc.filenameFor(Component.DATA));
             if (components.contains(Component.DATA) && dataFile.length() > 0)