don't change manifest level for cleanup, scrub, and upgradesstables under LCS patch by Maki Watanabe; reviewed by jbellis for CASSANDRA-3989
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/53fb52ac Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/53fb52ac Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/53fb52ac Branch: refs/heads/cassandra-1.1.0 Commit: 53fb52ac713e5471edd988b59cbd75f202a4f57b Parents: bc05b59 Author: Jonathan Ellis <jbel...@apache.org> Authored: Fri Mar 2 12:28:36 2012 -0600 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Fri Mar 2 12:29:51 2012 -0600 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ .../cassandra/db/compaction/LeveledManifest.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/53fb52ac/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index d23ff9c..ace4a9e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 1.0.9 + * don't change manifest level for cleanup, scrub, and upgradesstables + operations under LeveledCompactionStrategy (CASSANDRA-3989) * always compact away deleted hints immediately after handoff (CASSANDRA-3955) * delete hints from dropped ColumnFamilies on handoff instead of erroring out (CASSANDRA-3975) http://git-wip-us.apache.org/repos/asf/cassandra/blob/53fb52ac/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java index 189de8e..d74421f 100644 --- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java +++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java @@ -61,7 +61,6 @@ public class LeveledManifest private final List<SSTableReader>[] generations; private final DecoratedKey[] lastCompactedKeys; private final int maxSSTableSizeInMB; - private int levelCount; private LeveledManifest(ColumnFamilyStore cfs, int maxSSTableSizeInMB) { @@ -175,7 +174,13 @@ public class LeveledManifest if (!added.iterator().hasNext()) return; - int newLevel = minimumLevel == maximumLevel ? maximumLevel + 1 : maximumLevel; + // avoid increasing the level if we had a single source sstable involved. This prevents + // cleanup, scrub, and upgradesstables from blowing through the level cap. + // See CASSANDRA-3989 + int newLevel = Iterables.size(removed) == 1 + ? maximumLevel + : minimumLevel == maximumLevel ? maximumLevel + 1 : maximumLevel; + newLevel = skipLevels(newLevel, added); assert newLevel > 0; if (logger.isDebugEnabled()) @@ -295,6 +300,7 @@ public class LeveledManifest private void add(SSTableReader sstable, int level) { + assert level < generations.length : "Invalid level " + level + " out of " + (generations.length - 1); generations[level].add(sstable); }