cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Invalidate all caches on table drop
Date Fri, 15 Aug 2014 19:20:39 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 eab158462 -> ea686198f


Invalidate all caches on table drop

patch by Aleksey Yeschenko; reviewed by Benedict Elliott Smith for
CASSANDRA-7561


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

Branch: refs/heads/cassandra-2.1
Commit: 23233b384aede963c883a937adf94859edbd7f02
Parents: 561f6ef
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Fri Aug 15 22:14:17 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Aug 15 22:16:58 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java | 10 +++-------
 src/java/org/apache/cassandra/service/CacheService.java | 11 +++++++++++
 3 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/23233b38/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index dfe9c47..5b5283f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.0-rc6
+ * Invalidate all caches on table drop (CASSANDRA-7561)
  * Skip strict endpoint selection for ranges if RF == nodes (CASSANRA-7765)
  * Fix Thrift range filtering without 2ary index lookups (CASSANDRA-7741)
  * Add tracing entries about concurrent range requests (CASSANDRA-7599)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/23233b38/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 a0860a7..4842285 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -372,8 +372,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         data.unreferenceSSTables();
         indexManager.invalidate();
 
-        CacheService.instance.invalidateRowCacheForCf(metadata.cfId);
-        CacheService.instance.invalidateKeyCacheForCf(metadata.cfId);
+        invalidateCaches();
     }
 
     /**
@@ -2286,15 +2285,12 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 
     private void invalidateCaches()
     {
+        CacheService.instance.invalidateKeyCacheForCf(metadata.cfId);
         CacheService.instance.invalidateRowCacheForCf(metadata.cfId);
-
         if (metadata.isCounter())
-            for (CounterCacheKey key : CacheService.instance.counterCache.getKeySet())
-                if (key.cfId == metadata.cfId)
-                    CacheService.instance.counterCache.remove(key);
+            CacheService.instance.invalidateCounterCacheForCf(metadata.cfId);
     }
 
-
     /**
      * @return true if @param key is contained in the row cache
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/23233b38/src/java/org/apache/cassandra/service/CacheService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java
index f51a166..1b93c2c 100644
--- a/src/java/org/apache/cassandra/service/CacheService.java
+++ b/src/java/org/apache/cassandra/service/CacheService.java
@@ -310,6 +310,17 @@ public class CacheService implements CacheServiceMBean
         }
     }
 
+    public void invalidateCounterCacheForCf(UUID cfId)
+    {
+        Iterator<CounterCacheKey> counterCacheIterator = counterCache.getKeySet().iterator();
+        while (counterCacheIterator.hasNext())
+        {
+            CounterCacheKey counterCacheKey = counterCacheIterator.next();
+            if (counterCacheKey.cfId.equals(cfId))
+                counterCacheIterator.remove();
+        }
+    }
+
     public void invalidateCounterCache()
     {
         counterCache.clear();


Mime
View raw message