Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 7877d6f85 -> 0129f70c4 refs/heads/cassandra-2.2 477014b8c -> d1f6a1d95 refs/heads/cassandra-3.0 841a80311 -> 3c8a09767 refs/heads/cassandra-3.5 57cbda0a4 -> 87992c3a4 refs/heads/trunk 57cbda0a4 -> 87992c3a4
InvalidateKeys should have a weak ref to the key cache Patch by marcuse; reviewed by Ariel Weisberg for CASSANDRA-11176 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0129f70c Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0129f70c Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0129f70c Branch: refs/heads/cassandra-2.1 Commit: 0129f70c47d4a6b684fbf0df4dbbfb8ffc097d59 Parents: 7877d6f Author: Marcus Eriksson <marc...@apache.org> Authored: Thu Feb 25 08:57:35 2016 +0100 Committer: Marcus Eriksson <marc...@apache.org> Committed: Wed Mar 2 14:18:44 2016 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/io/sstable/SSTableRewriter.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/0129f70c/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 82ee99e..eed9035 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.14 + * InvalidateKeys should have a weak ref to key cache (CASSANDRA-11176) * Don't remove FailureDetector history on removeEndpoint (CASSANDRA-10371) * Only notify if repair status changed (CASSANDRA-11172) * Add partition key to TombstoneOverwhelmingException error message (CASSANDRA-10888) http://git-wip-us.apache.org/repos/asf/cassandra/blob/0129f70c/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java index af5d1d3..b56a5dc 100644 --- a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java +++ b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java @@ -17,6 +17,7 @@ */ package org.apache.cassandra.io.sstable; +import java.lang.ref.WeakReference; import java.util.*; import com.google.common.annotations.VisibleForTesting; @@ -339,12 +340,12 @@ public class SSTableRewriter private static final class InvalidateKeys implements Runnable { final List<KeyCacheKey> cacheKeys = new ArrayList<>(); - final InstrumentingCache<KeyCacheKey, ?> cache; + final WeakReference<InstrumentingCache<KeyCacheKey, ?>> cacheRef; private InvalidateKeys(SSTableReader reader, Collection<DecoratedKey> invalidate) { - this.cache = reader.getKeyCache(); - if (cache != null) + this.cacheRef = new WeakReference<InstrumentingCache<KeyCacheKey, ?>>(reader.getKeyCache()); + if (cacheRef.get() != null) { for (DecoratedKey key : invalidate) cacheKeys.add(reader.getCacheKey(key)); @@ -354,7 +355,11 @@ public class SSTableRewriter public void run() { for (KeyCacheKey key : cacheKeys) - cache.remove(key); + { + InstrumentingCache<KeyCacheKey, ?> cache = cacheRef.get(); + if (cache != null) + cache.remove(key); + } } }