cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [6/6] git commit: Fix concurrency issues with CQL keyspace creation
Date Mon, 20 Feb 2012 10:15:41 GMT
Fix concurrency issues with CQL keyspace creation

patch by slebresne; reviewed by thepaul for CASSANDRA-3903


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

Branch: refs/heads/trunk
Commit: 8f570ea68e50246ae825fa895f0e7fcf934e191b
Parents: 42175b6
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Feb 17 08:49:32 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Feb 17 08:53:40 2012 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 src/java/org/apache/cassandra/config/Schema.java   |   11 +++++++++--
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    5 ++---
 3 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8f570ea6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 069c1e3..259007e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
 1.1-dev
  * avoid unproductive deserializing of cached rows during compaction
    (CASSANDRA-3921)
+ * fix concurrency issues with CQL keyspace creation (CASSANDRA-3903)
 
 
 1.1-beta1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8f570ea6/src/java/org/apache/cassandra/config/Schema.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index 0c8ced4..e1047c2 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -409,8 +409,15 @@ public class Schema
      */
     public void fixCFMaxId()
     {
-        // never set it to less than 1000. this ensures that we have enough system CFids
for future use.
-        cfIdGen.set(cfIdMap.size() == 0 ? MIN_CF_ID : Math.max(Collections.max(cfIdMap.values())
+ 1, MIN_CF_ID));
+        int cval, nval;
+        do
+        {
+            cval = cfIdGen.get();
+            int inMap = cfIdMap.isEmpty() ? 0 : Collections.max(cfIdMap.values()) + 1;
+            // never set it to less than 1000. this ensures that we have enough system CFids
for future use.
+            nval = Math.max(Math.max(inMap, cval), MIN_CF_ID);
+        }
+        while (!cfIdGen.compareAndSet(cval, nval));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8f570ea6/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 92ae676..6d91d6e 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1511,11 +1511,10 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 
     public static Iterable<ColumnFamilyStore> all()
     {
-        Iterable<ColumnFamilyStore>[] stores = new Iterable[Schema.instance.getTables().size()];
-        int i = 0;
+        List<Iterable<ColumnFamilyStore>> stores = new ArrayList<Iterable<ColumnFamilyStore>>(Schema.instance.getTables().size());
         for (Table table : Table.all())
         {
-            stores[i++] = table.getColumnFamilyStores();
+            stores.add(table.getColumnFamilyStores());
         }
         return Iterables.concat(stores);
     }


Mime
View raw message