Fix cache persistence when both row and key cache are enabled patch by Mikhail Stepura and jbellis for CASSANDRA-6413
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/57613dc8 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/57613dc8 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/57613dc8 Branch: refs/heads/cassandra-2.0 Commit: 57613dc8c14d7213ee2d46d41bd642dd7cf697ab Parents: e40bc75 Author: Jonathan Ellis <jbel...@apache.org> Authored: Thu Dec 5 09:42:41 2013 -0600 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Thu Dec 5 09:42:41 2013 -0600 ---------------------------------------------------------------------- CHANGES.txt | 5 ++++- .../apache/cassandra/cache/AutoSavingCache.java | 22 ++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/57613dc8/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 09a3b07..166c566 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,7 +2,8 @@ * Fix thundering herd on endpoint cache invalidation (CASSANDRA-6345) * Optimize FD phi calculation (CASSANDRA-6386) * Improve initial FD phi estimate when starting up (CASSANDRA-6385) - * Don't list CQL3 table in CLI describe even if named explicitely (CASSANDRA-5750) + * Don't list CQL3 table in CLI describe even if named explicitely + (CASSANDRA-5750) * cqlsh: quote single quotes in strings inside collections (CASSANDRA-6172) * Improve gossip performance for typical messages (CASSANDRA-6409) * Throw IRE if a prepared statement has more markers than supported @@ -11,6 +12,8 @@ * Change snapshot response message verb to INTERNAL to avoid dropping it (CASSANDRA-6415) * Warn when collection read has > 65K elements (CASSANDRA-5428) + * Fix cache persistence when both row and key cache are enabled + (CASSANDRA-6413) 1.2.12 http://git-wip-us.apache.org/repos/asf/cassandra/blob/57613dc8/src/java/org/apache/cassandra/cache/AutoSavingCache.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java index d6a37df..a649e88 100644 --- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java +++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java @@ -299,22 +299,18 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K private void deleteOldCacheFiles() { File savedCachesDir = new File(DatabaseDescriptor.getSavedCachesLocation()); + assert savedCachesDir.exists() && savedCachesDir.isDirectory(); - if (savedCachesDir.exists() && savedCachesDir.isDirectory()) + for (File file : savedCachesDir.listFiles()) { - for (File file : savedCachesDir.listFiles()) - { - if (file.isFile() && file.getName().endsWith(cacheType.toString())) - { - if (!file.delete()) - logger.warn("Failed to delete {}", file.getAbsolutePath()); - } + if (!file.isFile()) + continue; // someone's been messing with our directory. naughty! - if (file.isFile() && file.getName().endsWith(CURRENT_VERSION + ".db")) - { - if (!file.delete()) - logger.warn("Failed to delete {}", file.getAbsolutePath()); - } + if (file.getName().endsWith(cacheType.toString()) + || file.getName().endsWith(String.format("%s-%s.db", cacheType.toString(), CURRENT_VERSION))) + { + if (!file.delete()) + logger.warn("Failed to delete {}", file.getAbsolutePath()); } } }