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 2013/12/07 11:31:21 UTC
git commit: Fix handling of concurrent directory creation failure
Updated Branches:
refs/heads/cassandra-1.2 86e949f32 -> 510eabfeb
Fix handling of concurrent directory creation failure
patch by Ryan Fowler; reviewed by Aleksey Yeschenko for
CASSANDRA-6459
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/510eabfe
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/510eabfe
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/510eabfe
Branch: refs/heads/cassandra-1.2
Commit: 510eabfeb4111b6acb27ce1c443e5aef99341d1d
Parents: 86e949f
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Sat Dec 7 13:30:26 2013 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Sat Dec 7 13:30:26 2013 +0300
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/db/Directories.java | 2 +-
.../apache/cassandra/db/DirectoriesTest.java | 22 ++++++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/510eabfe/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3b1f2f6..6f5f23b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,7 @@
* Fix cache persistence when both row and key cache are enabled
(CASSANDRA-6413)
* (Hadoop) add describe_local_ring (CASSANDRA-6268)
+ * Fix handling of concurrent directory creation failure (CASSANDRA-6459)
1.2.12
http://git-wip-us.apache.org/repos/asf/cassandra/blob/510eabfe/src/java/org/apache/cassandra/db/Directories.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java
index 351c0c0..8973327 100644
--- a/src/java/org/apache/cassandra/db/Directories.java
+++ b/src/java/org/apache/cassandra/db/Directories.java
@@ -448,7 +448,7 @@ public class Directories
if (!dir.isDirectory())
throw new AssertionError(String.format("Invalid directory path %s: path exists but is not a directory", dir));
}
- else if (!dir.mkdirs())
+ else if (!dir.mkdirs() && !(dir.exists() && dir.isDirectory()))
{
throw new FSWriteError(new IOException("Unable to create directory " + dir), dir);
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/510eabfe/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
index dce6f87..2c055c7 100644
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.db;
import java.io.File;
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.*;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -236,4 +237,25 @@ public class DirectoriesTest
DatabaseDescriptor.setDiskFailurePolicy(origPolicy);
}
}
+
+ @Test
+ public void testMTSnapshots() throws Exception
+ {
+ for (final String cf : CFS)
+ {
+ final Directories directories = Directories.create(KS, cf);
+ Assert.assertEquals(cfDir(cf), directories.getDirectoryForNewSSTables(0));
+ final String n = Long.toString(System.nanoTime());
+ Callable<File> directoryGetter = new Callable<File>() {
+ public File call() throws Exception {
+ Descriptor desc = new Descriptor(cfDir(cf), KS, cf, 1, false);
+ return directories.getSnapshotDirectory(desc, n);
+ }
+ };
+ List<Future<File>> invoked = Executors.newFixedThreadPool(2).invokeAll(Arrays.asList(directoryGetter, directoryGetter));
+ for(Future<File> fut:invoked) {
+ Assert.assertTrue(fut.get().exists());
+ }
+ }
+ }
}