cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/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/4af2bfee
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4af2bfee
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4af2bfee

Branch: refs/heads/trunk
Commit: 4af2bfee75493d828a89026340cad0c8dc1e62c5
Parents: 9c11763
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Feb 17 08:49:32 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Feb 20 11:13:05 2012 +0100

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


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4af2bfee/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a1a9a32..31a8a32 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@
  * avoid unproductive deserializing of cached rows during compaction
    (CASSANDRA-3921)
  * Show Effective Owership via Nodetool ring <keyspace> (CASSANDRA-3412)
+ * fix concurrency issues with CQL keyspace creation (CASSANDRA-3903)
+
 
 1.1-beta1
  * add nodetool rebuild_index (CASSANDRA-3583)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4af2bfee/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/4af2bfee/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 fcc5c25..dac9ded 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1519,11 +1519,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