You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/12/14 00:13:44 UTC
[2/3] git commit: Fix assertion failure in filterColdSSTables patch
by Tyler Hobbs; reviewed by jbellis for CASSANDRA-6483
Fix assertion failure in filterColdSSTables
patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-6483
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c9609759
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c9609759
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c9609759
Branch: refs/heads/trunk
Commit: c960975950560218cb5699e4961192081d119e45
Parents: 54c1ed3
Author: Jonathan Ellis <jb...@apache.org>
Authored: Fri Dec 13 17:12:47 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri Dec 13 17:12:47 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../SizeTieredCompactionStrategy.java | 21 ++++++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9609759/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a4b34ca..182bada 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.0.4
+ * Fix assertion failure in filterColdSSTables (CASSANDRA-6483)
* Fix row tombstones in larger-than-memory compactions (CASSANDRA-6008)
* Fix cleanup ClassCastException (CASSANDRA-6462)
* Reduce gossip memory use by interning VersionedValue strings (CASSANDRA-6410)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9609759/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index 09d4e8e..7ccc99d 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -90,12 +90,16 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
@VisibleForTesting
static List<SSTableReader> filterColdSSTables(List<SSTableReader> sstables, double coldReadsToOmit)
{
- // sort the sstables by hotness (coldest-first)
+ if (coldReadsToOmit == 0.0)
+ return sstables;
+
+ // Sort the sstables by hotness (coldest-first). We first build a map because the hotness may change during the sort.
+ final Map<SSTableReader, Double> hotnessSnapshot = getHotnessMap(sstables);
Collections.sort(sstables, new Comparator<SSTableReader>()
{
public int compare(SSTableReader o1, SSTableReader o2)
{
- int comparison = Double.compare(hotness(o1), hotness(o2));
+ int comparison = Double.compare(hotnessSnapshot.get(o1), hotnessSnapshot.get(o2));
if (comparison != 0)
return comparison;
@@ -190,12 +194,13 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
@VisibleForTesting
static Pair<List<SSTableReader>, Double> trimToThresholdWithHotness(List<SSTableReader> bucket, int maxThreshold)
{
- // sort by sstable hotness (descending)
+ // Sort by sstable hotness (descending). We first build a map because the hotness may change during the sort.
+ final Map<SSTableReader, Double> hotnessSnapshot = getHotnessMap(bucket);
Collections.sort(bucket, new Comparator<SSTableReader>()
{
public int compare(SSTableReader o1, SSTableReader o2)
{
- return -1 * Double.compare(hotness(o1), hotness(o2));
+ return -1 * Double.compare(hotnessSnapshot.get(o1), hotnessSnapshot.get(o2));
}
});
@@ -210,6 +215,14 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
return Pair.create(prunedBucket, bucketHotness);
}
+ private static Map<SSTableReader, Double> getHotnessMap(Collection<SSTableReader> sstables)
+ {
+ Map<SSTableReader, Double> hotness = new HashMap<>();
+ for (SSTableReader sstable : sstables)
+ hotness.put(sstable, hotness(sstable));
+ return hotness;
+ }
+
/**
* Returns the reads per second per key for this sstable, or 0.0 if the sstable has no read meter
*/