cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject cassandra git commit: Fix issue with data dir migration on upgrade
Date Fri, 04 Dec 2015 13:28:53 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 1e978df3a -> d0da9e761


Fix issue with data dir migration on upgrade

Patch by Stefania; reviewed by marcuse for CASSANDRA-10788


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

Branch: refs/heads/cassandra-3.0
Commit: d0da9e7612e6fb94fea8298a88215783a8125311
Parents: 1e978df
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Wed Dec 2 09:45:34 2015 +0800
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Fri Dec 4 14:22:26 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/SystemKeyspace.java | 10 +++++---
 .../apache/cassandra/db/SystemKeyspaceTest.java | 27 ++++++++++++++++++--
 3 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d0da9e76/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2527c43..520afff 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.1
+ * Fix issue with datadir migration on upgrade (CASSANDRA-10788)
  * Fix bug with range tombstones on reverse queries and test coverage for
    AbstractBTreePartition (CASSANDRA-10059)
  * Remove 64k limit on collection elements (CASSANDRA-10374)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d0da9e76/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 83c8c1c..8a27c9d 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -1324,14 +1324,18 @@ public final class SystemKeyspace
         Iterable<String> dirs = Arrays.asList(DatabaseDescriptor.getAllDataFileLocations());
         for (String dataDir : dirs)
         {
-            logger.trace("Checking directory {} for old files", dataDir);
+            logger.trace("Checking {} for old files", dataDir);
             File dir = new File(dataDir);
             assert dir.exists() : dir + " should have been created by startup checks";
 
-            for (File ksdir : dir.listFiles((d, n) -> d.isDirectory()))
+            for (File ksdir : dir.listFiles((d, n) -> new File(d, n).isDirectory()))
             {
-                for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
+                logger.trace("Checking {} for old files", ksdir);
+
+                for (File cfdir : ksdir.listFiles((d, n) -> new File(d, n).isDirectory()))
                 {
+                    logger.trace("Checking {} for old files", cfdir);
+
                     if (Descriptor.isLegacyFile(cfdir))
                     {
                         FileUtils.deleteRecursive(cfdir);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d0da9e76/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
index 9fc3503..d770610 100644
--- a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
+++ b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
@@ -153,6 +153,29 @@ public class SystemKeyspaceTest
     }
 
     @Test
+    public void testMigrateEmptyDataDirs() throws IOException
+    {
+        File dataDir = Paths.get(DatabaseDescriptor.getAllDataFileLocations()[0]).toFile();
+        if (new File(dataDir, "Emptykeyspace1").exists())
+            FileUtils.deleteDirectory(new File(dataDir, "Emptykeyspace1"));
+        assertTrue(new File(dataDir, "Emptykeyspace1").mkdirs());
+        assertEquals(0, numLegacyFiles());
+        SystemKeyspace.migrateDataDirs();
+        assertEquals(0, numLegacyFiles());
+
+        assertTrue(new File(dataDir, "Emptykeyspace1/table1").mkdirs());
+        assertEquals(0, numLegacyFiles());
+        SystemKeyspace.migrateDataDirs();
+        assertEquals(0, numLegacyFiles());
+
+        assertTrue(new File(dataDir, "Emptykeyspace1/wrong_file").createNewFile());
+        assertEquals(0, numLegacyFiles());
+        SystemKeyspace.migrateDataDirs();
+        assertEquals(0, numLegacyFiles());
+
+    }
+
+    @Test
     public void testMigrateDataDirs_2_1() throws IOException
     {
         testMigrateDataDirs("2.1");
@@ -185,9 +208,9 @@ public class SystemKeyspaceTest
         for (String dataDir : dirs)
         {
             File dir = new File(dataDir);
-            for (File ksdir : dir.listFiles((d, n) -> d.isDirectory()))
+            for (File ksdir : dir.listFiles((d, n) -> new File(d, n).isDirectory()))
             {
-                for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
+                for (File cfdir : ksdir.listFiles((d, n) -> new File(d, n).isDirectory()))
                 {
                     if (Descriptor.isLegacyFile(cfdir))
                     {


Mime
View raw message