You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2020/10/20 07:25:25 UTC

[cassandra] branch cassandra-3.11 updated: Synchronize Keyspace instance store/clear

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.11 by this push:
     new bca91ca  Synchronize Keyspace instance store/clear
bca91ca is described below

commit bca91ca84b9daf8b9e3d361975a535b90b4f77fa
Author: Ekaterina Dimitrova <ek...@datastax.com>
AuthorDate: Wed Oct 14 10:34:39 2020 -0400

    Synchronize Keyspace instance store/clear
    
     patch by Ekaterina Dimitrova; reviewed by Mick Semb Wever for CASSANDRA-16210
---
 CHANGES.txt                                      |  1 +
 src/java/org/apache/cassandra/config/Schema.java | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index df8e6ba..6c41cee 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.9
+ * Synchronize Keyspace instance store/clear (CASSANDRA-16210)
  * Fix ColumnFilter to avoid querying cells of unselected complex columns (CASSANDRA-15977)
  * Fix memory leak in CompressedChunkReader (CASSANDRA-15880)
  * Don't attempt value skipping with mixed version cluster (CASSANDRA-15833)
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index 253a66b..7c2028b 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -205,10 +205,8 @@ public class Schema
      */
     public void storeKeyspaceInstance(Keyspace keyspace)
     {
-        if (keyspaceInstances.containsKey(keyspace.getName()))
+        if (keyspaceInstances.putIfAbsent(keyspace.getName(), keyspace) != null)
             throw new IllegalArgumentException(String.format("Keyspace %s was already initialized.", keyspace.getName()));
-
-        keyspaceInstances.put(keyspace.getName(), keyspace);
     }
 
     /**
@@ -653,9 +651,11 @@ public class Schema
             droppedCfs.add(cfm.cfId);
         }
 
-        // remove the keyspace from the static instances.
-        Keyspace.clear(ksm.name);
-        clearKeyspaceMetadata(ksm);
+        synchronized (Keyspace.class) {
+            // Remove the keyspace from the static instances.
+            Keyspace.clear(ksm.name);
+            clearKeyspaceMetadata(ksm);
+        }
 
         Keyspace.writeOrder.awaitNewBarrier();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org